Tuesday 29 July 2014

Bestseller products in Magento

If you search around the web for how to create a Magento bestsellers page then the core PHP snippet suggested to generate the bestsellers data is a variation on the following: - See more at: http://www.zodiacmedia.co.uk/blog/magento-bestselling-products#sthash.ZS65Z56j.dpuf
If you search around the web for how to create a Magento bestsellers page then the core PHP snippet suggested to generate the bestsellers data is a variation on the following: - See more at: http://www.zodiacmedia.co.uk/blog/magento-bestselling-products#sthash.ZS65Z56j.dpuf
If you search around the web for how to create a Magento bestsellers page then the core PHP snippet suggested to generate the bestsellers data is a variation on the following: - See more at: http://www.zodiacmedia.co.uk/blog/magento-bestselling-products#sthash.ZS65Z56j.dpuf
If you search around the web for how to create a Magento bestsellers page then the core PHP snippet suggested to generate the bestsellers data is a variation on the following: - See more at: http://www.zodiacmedia.co.uk/blog/magento-bestselling-products#sthash.ZS65Z56j.dpuf

If you search around the web for how to create a Magento bestsellers page then the core PHP snippet suggested to generate the bestsellers data is a variation on the following:

<?php
            $_categoryId = 'CATEGORY_ID';
            $catagory_model = Mage::getModel('catalog/category')->load($_categoryId); //where $category_id is the id of the category
            $collection = Mage::getResourceModel('catalog/product_collection');
            $collection->addCategoryFilter($catagory_model1); //category filter
            $collection->addAttributeToFilter('status',1); //only enabled product
            $collection->addAttributeToSelect(array('name','price','url','small_image')); //add product attribute to be fetched
            $collection->setOrder('id', 'DESC');
            $collection->setPage(1,8);
            $collection->addStoreFilter();   ?>

 <?php 
        if(!empty($collection)):
                foreach ($collection as $_product): ?>
                  <li>
          <a href="<?php echo $_product1->getProductUrl(); ?>">
      <img src="<?php echo $this->helper('catalog/image')->init($_product1, 'small_image')->resize(218,115); ?>"  alt="" />
    </a>
 <a href="<?php echo $_product1->getProductUrl(); ?>">
                    <h3><?php echo $_product1->getName(); ?></h3>
                    </a>
<span class="price"><?php echo $_product1->getFinalPrice(); ?></span>
</li>
                  <?php
            endforeach;
            endif;       
        ?>        

No comments:

Post a Comment