<?php
$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel('reports/product_collection')
->addOrderedQty()
->addAttributeToSelect('*')
->addAttributeToSelect(array('name', 'price', 'small_image'))
->setStoreId($storeId)
->addStoreFilter($storeId)
->setOrder('ordered_qty', 'desc');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
if($categoryId=$this->getData('category_id')){
$category = Mage::getModel('catalog/category')->load($categoryId);
$products->addCategoryFilter($category);
}
//$products->setPageSize(5)->setCurPage(1); // change the Page Size to how many products you want to show per category
$this->setProductCollection($products);
?>
<?php if (($_products = $this->getProductCollection())): ?>
<div class="page-title">
<h2><?php echo $this->__('Our Top Selling Product') ?></h2>
</div>
<div class="top-products owl-carousel">
<?php foreach ($_products->getItems() as $_product): ?>
<div>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300); ?>" width="300" height="300" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel('reports/product_collection')
->addOrderedQty()
->addAttributeToSelect('*')
->addAttributeToSelect(array('name', 'price', 'small_image'))
->setStoreId($storeId)
->addStoreFilter($storeId)
->setOrder('ordered_qty', 'desc');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
if($categoryId=$this->getData('category_id')){
$category = Mage::getModel('catalog/category')->load($categoryId);
$products->addCategoryFilter($category);
}
//$products->setPageSize(5)->setCurPage(1); // change the Page Size to how many products you want to show per category
$this->setProductCollection($products);
?>
<?php if (($_products = $this->getProductCollection())): ?>
<div class="page-title">
<h2><?php echo $this->__('Our Top Selling Product') ?></h2>
</div>
<div class="top-products owl-carousel">
<?php foreach ($_products->getItems() as $_product): ?>
<div>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(300); ?>" width="300" height="300" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
Comments
Post a Comment