July 12, 2020


Thinking Magento

Create A Magento On Sale Category - The RIGHT Way

In a previous blog entry a few years back I wrote out a way to get sale products to show only. It's cumbsersome and not very elegant and work at a time when Magento was still fairly new.

In this entry I'm going to show you a revised way of doing this, which could be applied to filtering collections of any type such as price ranges, new products, custom attributes, date added etc, it's a fairly extensive list, which can be mapped in the .php file that you can find lower in the article.

So lets start with your category. Navigate in your admin to the category that you wish to show sale products only.

Catalog > Manage Categories or in EE Catalog > Categories > Manage Categories

Click on the category and go to the custom design tab and paste into the custom design layout box the following

<reference name="content">
<remove name="product_list"/>
<block type="catalog/product_sale" name="product_sale" alias="sale" template="catalog/product/list.phtml">
<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="setLimit"><limit>32</limit></action>
<action method="setColumnCount"><columns>3</columns></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
<action method="addPriceBlockType">
<reference name="product_list_toolbar">
<action method="setDefaultGridPerPage">

One you've added that and saved, going to the category is going to produce an error because it's looking for the file Mage_Catalog_Block_Product_Sale.

Click here for file

Log in via ftp or sftp and place the file into app/code/local/Mage/Catalog/Block/Product/Sale

Going to the category will now show you only on sale products that are in stock.

Open up the Sale.php file if you wish to addAttributeToFilter. 

This tutorial is designed for those who just want to get the job done and out of the way and everyone needs a sale category the easy way.

If this saved you hours of work or saved you from a headache, feel free to buy us a beer.