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.
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.
Personally I would have a hidden category with all products in it and use a script to keep that updated to be all products. The script can be done with the API, slow yes, but it will work in a timely fashion for a certain level of SKU count.
layer navigation is include in category view. You should include the part of navigation used by category, so try to insert
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
</reference>
before
<reference name="content">
I'm not sure but if it's doesn't works it should help you to understand the problem anyway
check the following pages ( they came across the same problem )
http://www.exploremagento.com/magento/some-custom-blocks-to-help-you-show-products.php http://www.chilipepperdesign.com/2009/03/23/magento-how-to-list-all-the-products-in-a-single-category-in-a-sidebar-block
来源:https://stackoverflow.com/questions/5184241/magento-custom-product-list