Step one
Open your homepage CMS page and click on the design tab. Paste the following:
You can then paste this into a file and name it specials.phtml and save it into your frontend template folder catalog/product.
Open your homepage CMS page and click on the design tab. Paste the following:
<reference name="content">
<remove name="product_list"/>
<remove name="category.products"/>
<block before="-" type="catalog/product" name="home.new" alias="product" template="catalog/product/specials.phtml"> <action method="setProductsCount"><count>9</count></action>
</block>
</reference>
<remove name="product_list"/>
<remove name="category.products"/>
<block before="-" type="catalog/product" name="home.new" alias="product" template="catalog/product/specials.phtml"> <action method="setProductsCount"><count>9</count></action>
</block>
</reference>
Step two:
First of all this is the code were that we're going to be using to do this.
<?php
Mage::getSingleton('core/session', array('name' => 'frontend'));
$_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection')
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addStoreFilter();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($_productCollection);
$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);
$_productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $tomorrowDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');
echo '<div class="listing-type-grid catalog-listing">';
$_collectionSize = $_productCollection->count();
$i=0; foreach($_productCollection as $_product):
if($i++%3==0)
echo '<ol class="grid-row">';
echo '<li class="item">';
echo '<p class="product-image">';
echo '<a href="'.$_product->getProductUrl().'" title="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'">';
echo '<img src="'.$this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135).'" width="135" height="135" alt="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'" title="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'" />
</a>
</p>';
echo '<h5><a href="'.$this->getProductUrl().'" title="'.$this->htmlEscape($_product->getName()).'">'.$this->htmlEscape($_product->getName()).'</h5>';
echo $this->getPriceHtml($_product, true) ?>
</li>
<?php if($i%3==0 || $i==$_collectionSize): ?>
</ol>
<?php endif; ?>
<?php endforeach ?>
</div>
Mage::getSingleton('core/session', array('name' => 'frontend'));
$_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection')
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addStoreFilter();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($_productCollection);
$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);
$_productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $tomorrowDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');
echo '<div class="listing-type-grid catalog-listing">';
$_collectionSize = $_productCollection->count();
$i=0; foreach($_productCollection as $_product):
if($i++%3==0)
echo '<ol class="grid-row">';
echo '<li class="item">';
echo '<p class="product-image">';
echo '<a href="'.$_product->getProductUrl().'" title="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'">';
echo '<img src="'.$this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135).'" width="135" height="135" alt="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'" title="'.$this->htmlEscape($this->getImageLabel($_product, 'small_image')).'" />
</a>
</p>';
echo '<h5><a href="'.$this->getProductUrl().'" title="'.$this->htmlEscape($_product->getName()).'">'.$this->htmlEscape($_product->getName()).'</h5>';
echo $this->getPriceHtml($_product, true) ?>
</li>
<?php if($i%3==0 || $i==$_collectionSize): ?>
</ol>
<?php endif; ?>
<?php endforeach ?>
</div>
You can then paste this into a file and name it specials.phtml and save it into your frontend template folder catalog/product.
thanks this is very usefull for me..........
ReplyDeleteThanks it is very helpfull for me...
ReplyDeleteThis comment has been removed by the author.
ReplyDelete