简体   繁体   English

Magento,定制产品清单

[英]Magento, custom product list

I made my own product list page based on Mage_Catalog_Block_Product_List: 我根据Mage_Catalog_Block_Product_List创建了自己的产品列表页面:

app/code/local/Mage/Catalog/Block/Product/Special.php: 应用程序/代码/本地/法师/目录/座/产品/ 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: 我将其包含在中心列的CMS页面中:

<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. Mage_Catalog_Block_Product_Special只是一个代理类。 This doesn't work. 这不起作用。 Even if I use block type "catalog/product_list" on my CMS page I will not get a layered navigation. 即使我在CMS页面上使用块类型“catalog / product_list”,我也不会获得分层导航。
  • 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'. 我也尝试创建自己的模块并将其列在例如'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. 我有一种感觉,这与尝试在CMS页面上包含产品列表有关,但我无法找到确切的问题。

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: 如果查看catalog.xml ,您将看到catalog_category_layered节点包含以下内容:

<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. 因此,将其添加到CMS xml布局更新中,并且应该在CMS页面上显示图层块。

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. 如果您在单击其中一个可过滤属性时遇到产品列表未被过滤的问题,那可能是因为Layer_View块呈现的链接假定​​它们将回发到CategoryController ,而不是将要呈现的CmsController您的CMS页面。 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. 该脚本可以使用API​​完成,但是很慢,但它可以及时处理某个SKU计数级别。

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 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-所有的产品功能于一个单类别-IN-A-侧边栏块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM