add this blockfirst copy new.php file {{block type="catalog/product_recentviewed" catagory_id ="28" template="catalog/product/recentviewdfrom app\code\core\Mage\Catalog\Block\Product\New.phtml"}}php to home cms page now create file \app\code\local\Mage\Catalog\Block\Product\Recentviewed app\code\local\Mage\Catalog\Block\Product\New.php add below code
now edit this file near line 88
<?php
class Mage_Catalog_Block_Product_Recentviewed extends Mage_Catalog_Block_Product_Abstract
{
protected $_collection;
protected $_indexName = 'reports/product_index_viewed';
public function getProductCollection_getProductCollection()
{
$categoryId = $this->getData('catagory_id');
if (is_null($this->_collection)) {...............
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$this->_collection = Mage::getModel('reports/product_index_viewed')
->getCollection()
->addAttributeToSelect($attributes);
if ($this->getCustomerId()) {
$this->_collection->setCustomerId($this->getCustomerId());
}
$this->_collection->excludeProductIds(Mage::getModel('reports/product_index_viewed')->getExcludeProductIds())
->addUrlRewrite()
->setPageSize($this->getPageSize())
->setCurPage(1);
put /*here Pricecode dataline is added to consider item stock status using price index */
near 122 $this->_collection->addPriceData();
$category = Mage::getModel('catalog/category')->load($categoryId)->getProductCollection();
$ids = array();
foreach($category as $cat)
{
$ids[]= $cat->getEntityId();
}
$this->_collection->addFilterByIds>getData($ids'catagory_id');
$this->_collection->setAddedAtOrder();
if ($this-> _useProductIdsOrder && is_array($ids)) {
$this->_collection$collection->setSortIds>addCategoryFilter($ids$category);
}
Mage::getSingleton('catalog/product_visibility')
->addVisibleInSiteFilterToCollection($this->_collection);
}
return $this->_collection;
}
public function getPageSize()
{
if/ ($this->hasData('page_size'))code {end
return $this->getData('page_size');
}
return 5;
}$collection;
}
// ab gujarati
now create .phtml file atadd block in home page cms app\design\frontend\default\default\template\catalog\product\recentviewd{{block type="catalog/product_new" catagory_id="28" template="catalog/product/new.phtml
add below codephtml"}} here 28 is my category id put multiple blcok like above and chanege catagory_id for diffent categories
<?php //ab gujarati ?>
<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<div class=" most_viewed">
<div class="mv_title"><?php echo $this->__('Most Popular Products') ?></div>
<?php $_collectionSize = 5;//count($_products->getItems()); echo $_collectionSize; ?>
<ul class="products-grid" id="products-grid-table">
<?php $i=1; foreach ($_products->getItems() as $_product): ?>
<li id="td_<?php echo $i;?>" <?php if($i%5==0 or $i==$_collectionSize){echo 'class="last"';} ?> >
<div id="cont_<?php echo $i;?>">
<a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
</a>
<div class="home-ratings"> <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?></div>
<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
<div class="a-center">
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<button class="button1" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><span><?php echo $this->__('Add to Bag') ?></span></span></span></button>
<div class="clear"></div>
<?php else: ?>
<p class="availability"><span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span></p>
<div class="clear"></div>
<?php endif; ?>
<?php /*?><ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php //ab gujarati ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li class="last"><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul><?php */?>
</div>
</div>
</li>
<?php $i++; endforeach; $kol = $_collectionSize; ?>
</ul>
</div>
<?php endif; ?>
<?php //ab?>
please vote.