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
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
really wonderful post. Thanks for sharing this wonderful information.
ReplyDeleteNeed your appreciation to continue my effort.....
ReplyDeleteThanks very much, really helpful, can u tell me how to make page for latest producs , like this ? with thanks
ReplyDelete1) Create a file "/app/code/local/Mage/Catalog/Block/Product/Special.php "
ReplyDeletewith following contents:
in my magento /app/code/core/Mage/Catalog/Block/Product/
Add filter in line 43: ->addAttributeToFilter('special_price', array('gt' => 0));
ReplyDeleteit filters the promotion products without price set.
I made a Brazilian version, available at: http://adonaidiofanes.com.br/blog/magento-criar-uma-pagina-com-produtos-em-promocao/
Hi,
ReplyDeleteNice method and works great, but the products on offer set in the catalog price rules are not displayed. Any solution to this?
thanks
bookmark first.i'm using magento 1.7.0.2 doest that work too? Thanks!
ReplyDeleteVery useful and good post.............really helpful.....
ReplyDeletehttp://trimurtyinfotech.com/dev/bts/shop-by-brand/?manufacturer=59
i want to add toolbar on this page, how to do this.
I mean i want to add toolbar on brand page. please hepl me ASAP.
In that pager is not working...give me some hope guys
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGreat Read! I am impressed on how you make your article easy to understand. I'll come back for more :D
ReplyDeleteoffshore magento development
The filter is not working, all products with a special price are being displayed. How can I fix this? My version of magento is 1.9.2.4
ReplyDeleteI do agree with all the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time?..Keep this great work
ReplyDeletemagento development company in bangalore
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteBest Devops training in sholinganallur
Devops training in velachery
Devops training in annanagar
Devops training in tambaram
Great content thanks for sharing this informative blog which provided me technical information keep posting.
ReplyDeleteSelenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
From your discussion I have understood that which will be better for me and which is easy to use. Really, I have liked your brilliant discussion. I will comThis is great helping material for every one visitor. You have done a great responsible person. i want to say thanks owner of this blog.
ReplyDeletepython Training in Pune
python Training in Chennai
python Training in Bangalore
Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
ReplyDeletepython training in bangalore
ReplyDeleteGreat Post!!! thanks for sharing it with us.
selenium project for practice