Sunday, July 8, 2012

how to view popular products in magento? or maximum sold products in store


getStore()->getStoreId(); $this->_productCollection = Mage::getResourceModel('reports/product_collection');
if ($this->getTimeLimit())
{
$product = Mage::getModel('catalog/product');
$todayDate = $product->getResource()->formatDate(time());
$startDate = $product->getResource() ->formatDate(time() - 60 * 60 * 24 * $this ->getTimeLimit());
$this->_productCollection = $this->_productCollection ->addOrderedQty($startDate, $todayDate);
}
else
{
$this->_productCollection = $this->_productCollection ->addOrderedQty();
}
$intNumRecord = Mage::getStoreConfig('banner/carousel_configuration/bestseller_number_product');
$this->_productCollection = $this->_productCollection ->addAttributeToSelect('*') ->setStoreId($storeId) ->addStoreFilter($storeId) ->setOrder('ordered_qty', 'desc') ->setPageSize($intNumRecord);
$_productCollection = $this->_productCollection ->setPageSize($intNumRecord);
if($_productCollection->count())
{ ?>
load($_products->getId());?>getShortDescription();if(strlen($strproductdescription)>82) $strproductdescription = trim(substr($strproductdescription,0,81)."...");$strProductName = $_product->getName(); ?> 22){$strProductName =  substr($strProductName,0,21)."...";}?>
<a href="getProductUrl() ?>" title="stripTags($_product->getName(), null, true) ?>">

<a href="getUrl('popular-products');?>">__('More...');?>

No comments:

Post a Comment

Please mention your comments.......