How to setup a page showing the “special price products” in Magento.
First step:
Create a new page named “Specials” (or whatever you want) in Admin->CMS->Pages and insert into “Custom Layout XML” field this code:
<reference name="content"> <block after="-" type="catalog/product_list" name="offerte.new" alias="offerte" template="catalog/product/specials.phtml"> <action method="setProductsCount"><count>15</count></action> </block> </reference>
select your layout (2, 3 columns ) and save.
Second Step:
Create this file:
app/design/frontend/default/YOURTHEME/template/catalog/product/specials.phtml
Populate the file with this content:
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');
and with the content taken from
app/design/frontend/default/YOURTHEME/template/catalog/product/list.phtml
WITHOUT THIS LINE:
$_productCollection=$this->getLoadedProductCollection();
Save your template file and enjoy your specials page…
November 12, 2013 at 8:16 pm
Thanks for this nice solution! It nicely shows all products that have a discounted price on one page.
One question though: This page doesn’t show the toolbar (with the sort-by, sort-order and number of products to show per page). Also, it doesn’t follow the global sort rule (by name).
Any idea how that can be fixed? Thanks!
February 11, 2014 at 10:31 pm
Thanks but it doesn’t work. There is no error message but no list – just empty.
The only difference: the special.phtml can be found under
/app/design/frontend/THEMENAME/default/template/catalog/product/
in Magento Community Version 1.8.1
Thanks in advance!
February 11, 2014 at 10:44 pm
I found the bug.
In Layout XML you are talking about specials.phtml, later on the file should be named special.phtml. So, the ‘s’ is missing.
Regards Friedemann
March 27, 2014 at 12:19 pm
Thank you for the bug report and the fix! We’ve updated the post
May 30, 2014 at 5:59 am
Hi, on Magento ver. 1.8.1.0
showing me all product instead only Special
instead “$_productCollection=$this->getLoadedProductCollection();”
I paste code “Mage::getSingleton(‘core/session’, array(‘name’ => ‘frontend’));…….”
what I doing wrong? in CMS on new page named “Specials” Page Information -> Content–> required field, what put under Content?
Best Regards thanks for help
June 10, 2014 at 3:00 pm
How can I add default pagination ?
June 18, 2014 at 2:08 pm
thank you for this post. It worked perfectly for me on magento 1.9.0.1
April 14, 2015 at 12:02 am
This only seems to pull up the special price items and not the catalog price rule items. Is there a way to pull them up too?
October 1, 2015 at 12:37 pm
my special price is not working in shopping cart, will anybody plz help me…