Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento, custom product list

I made my own product list page based on Mage_Catalog_Block_Product_List:

app/code/local/Mage/Catalog/Block/Product/Special.php:

class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List
{      
    /* Original contents */

    /* Here I call addAttributeToFilter on product collection, and then... */
    return $this->_productCollection; 
}

I include this in a CMS page on the center column:

<reference name="content">
    <block type="catalog/product_special" template="catalog/product/list.phtml" />
</reference>

The problem is: The product list shows up just fine, but I get no layered navigation in my left column.

This is quite strange, since I am using exactly the same template as normal listings.

A couple of things I have checked:

  • Mage_Catalog_Block_Product_Special just being a proxy class. This doesn't work. Even if I use block type "catalog/product_list" on my CMS page I will not get a layered navigation.
  • There are no extensions that are overriding crucial core classes.
  • I have also tried to create my own module and list it under for example 'mycatalog'. This results in exactly the same problem.

I have a feeling this has to do with trying to include a product listing on a CMS page but I have not been able to track down the exact problem.

Any help on this would be very much appreciated.

like image 890
Daniel Sloof Avatar asked Oct 11 '22 14:10

Daniel Sloof


1 Answers

You need to add the Block that renders the Layers into the left column.

If you look in catalog.xml, you will see that the catalog_category_layered node includes the following:

<reference name="left">
        <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
        ...
</reference>

So, add that into your CMS xml layout update and that should display the Layer block on your CMS page.

If you have issues with the product list not being filtered when you click one of the filterable attributes, that is probably because the links rendered by the Layer_View Block assume that they are going to post back to a CategoryController, not a CmsController which will be rendering your CMS page. That may or may not be an issue, so report back here if it doesn't work and we can try to work through it.

like image 75
Jonathan Day Avatar answered Oct 18 '22 15:10

Jonathan Day