Setup a Magento Special Price Products Page Howto

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: (Can be a bit different depeding on Mage version or template)

$_productCollection=$this->getLoadedProductCollection();

Save your template file and enjoy your specials page…

Hebt u meer vragen? Een aanvraag indienen

Opmerkingen

Mogelijk gemaakt door Zendesk