0

We have various sale products for limited times.

How best to display these so that it's easy to end old sales and start new ones?

I was thinking of creating a CMS Page "Sale Products."

If the CMS page includes layered navigation, then I could link to various sales by filtering by Manufacturer.

Suppose I have Acme Widgets in categories "Deluxe" and "Standard". If Acme Widgets has a sale on deluxe widgets and standard widgets, and I want to have separate banners for each on the homepage, would it be possible to include the category as a layered navigation option inside the CMS page, so that I could directly link to filtered results by category?

Or would I have to rely on normal attributes?

Also, should I create a module to do this, or just write code inside of a custom CMS block in app/design/frontend/default/my_theme/template/cms/ ?

I will probably need a way of retrieving custom product collections based on sale prices, and cms might not be the right place to write that code.

Thanks

2 Answers 2

1

I would stay away from the cms page idea. In the end it will need a lot of manual maintenance.

I gather you are using the 'special from / to' date ranges on your sale products?

Magento has a built in block/template to display new products. see Mage_Catalog_Block_Product_New and its corresponding template file design/frontend/base/default/template/catalog/product/new.phtml

You could use these as examples/staring point to create a new block / template to display products that are in sale. The new block uses the new from/to date ranges, and you'd just need to swap that to special from/to date ranges attributes.

And some blatant self module promotion, as a second option :)

I created a module that hooks into magento's category system, and allows you to create a category (ie sale) and then dynamically assign products to that category (using any product attribute, in your case special from/to date range)

Since this is a real category, you get all the normal category layered navigation and catgeory related functionality (banners etc). All my code does is inject a new collection to the category on display, thus making it dynamic.

http://www.proxiblue.com.au/magento-dynamic-category-products.html

1
  • Thanks for your answer. You say to stay away from CMS pages. But then where do I display these products? Where would I put this block? I would like to have it so the user clicks a link to a sale banner on the home page and it takes you a catalog-like page with a particular collection of sale products (or, perhaps to all sale products with pre-activated user filters that will show the correct products). Commented Nov 13, 2013 at 4:55
1

It is possible to do this using CMS pages (but probably not recommended) by adding a custom extension block in the CMS page to load the products grid.

This extension would need a template to render the products to a list or grid or whatever you would like and a block class behind it that retrieves the collection.

Haven't tested the code but it would be something along the lines of this for a block class:

class Acme_Salespage_Block_Grid extends Mage_Core_Block_Template
{

    public function getCollection()
    {
        $category = Mage::getModel('catalog/category')->load((int)$this->getData('category'));

        $collection = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToSelect('name')
            [...]
            whatever you want to select here
            [...]
            ->addCategoryFilter($category)
            ->addAttributeToFilter('status', 1)
            ->addAttributeToFilter('special_from_date', array('date' => true, 'to' => Mage::getModel('core/date')->gmtDate()))
            ->addAttributeToFilter('special_to_date', array('date' => true, 'gteq' => Mage::getModel('core/date')->gmtDate()))
            ->addAttributeToFilter('visibility', array( 'in' => array(
                Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
            ) ));

        Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);

        return $collection;
    }
}

And then retrieve the products in your extensions template file using the getCollection method.

Now all you need to do is call this block in the CMS page using the custom layout XML.

[...]
    <reference name="content">
        <block type="salespage/grid" naem="acme_salespage_grid" template="salespage/grid.phtml">
            <action method="setCategory"><category>5</category></action>
        </block>
    <reference name="content">
[...]

Where you pass along the category ID your sales items for that specific brand are in.

Now this CMS page will display only products that are on sale and in the category you intended.

Not the answer you're looking for? Browse other questions tagged or ask your own question.