Magento : Special product Page
For showing special products(products which have special price) in a cms page ,
follow the below steps:
1) Create a file "/app/code/local/Mage/Catalog/Block/Product/Special.php "
with following contents:
<?php
if(version_compare(Mage::getVersion(), '1.4.0.0', '>=') || version_compare(Mage::getVersion(), '1.6.0.0', '<=')){
//Code
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List
{
function get_prod_count()
{
//unset any saved limits
Mage::getSingleton('catalog/session')->unsLimitPage();
return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 12;
}// get_prod_count
function get_cur_page()
{
return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1;
}// get_cur_page
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
**/
protected function _getProductCollection()
{
$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);
$collection = Mage::getResourceModel('catalogsearch/advanced_collection')
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addStoreFilter();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
$collection->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');
$this->setProductCollection($collection);
return $collection;
}// _getProductCollection
}// Mage_Catalog_Block_Product_Special
}
2) Create a CMS page "SPECIAL" by going to
Magento -> Admin ->CMS -> Pages
3) In the above CMS page
Go to Design-> Layout Update XML
and
Paste
<reference name="content">
<block type="catalog/product_special" name="product_new" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>10</category_id></action>
<action method="setColumnCount"><column_count>6</column_count></action>
<action method="setProductsCount"><count>0</count></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager" />
<action method="setDefaultGridPerPage"><limit>12</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>36</limit></action>
<action method="addPagerLimit"><mode>grid</mode><limit>48</limit></action>
<action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
</block>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>6</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>
Your CMS Page is created .
You can see your page at
www.yoursite.com/SPECIAL
---------------------------------------------------------------------------------------------------
If you want special product on homepage
Paste
<reference name="content">
<block type="catalog/product_special" name="catalog_product_special" as="product_homepage" template="catalog/product/lists.phtml"/>
</reference>
in Layout Update XML of "Home Page" CMS
A useful link also is available at:
http://www.dnawebagency.com/displaying-new-products-in-magento-with-pagination