Magento,自定义产品列表

发布于 2024-10-20 04:29:34 字数 948 浏览 8 评论 0原文

我根据 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; 
}

我将其包含在中心列的 CMS 页面中:

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

问题是:产品列表显示得很好,但我的左栏中没有分层导航。

这很奇怪,因为我使用与正常列表完全相同的模板。

我检查了几件事:

  • Mage_Catalog_Block_Product_Special 只是一个代理类。这是行不通的。即使我在 CMS 页面上使用块类型“catalog/product_list”,我也不会获得分层导航。
  • 没有任何扩展会覆盖关键的核心类。
  • 我还尝试创建自己的模块并将其列在例如“mycatalog”下。这会导致完全相同的问题。

我有一种感觉,这与尝试在 CMS 页面上包含产品列表有关,但我无法找到确切的问题。

对此的任何帮助将非常感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

泪意 2024-10-27 04:29:34

您需要将渲染图层的块添加到左列中。

如果您查看 catalog.xml,您将看到 catalog_category_layered 节点包含以下内容:

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

因此,将其添加到您的 CMS xml 布局更新中,并且应该显示 Layer 块在您的 CMS 页面上。

如果您在单击可过滤属性之一时遇到产品列表未被过滤的问题,这可能是因为 Layer_View 块呈现的链接假定​​它们将回发到 CategoryController,不是将呈现您的 CMS 页面的 CmsController。这可能是问题,也可能不是问题,所以如果它不起作用,请在此处报告,我们可以尝试解决它。

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.

避讳 2024-10-27 04:29:34

就我个人而言,我会拥有一个包含所有产品的隐藏类别,并使用脚本将其更新为所有产品。该脚本可以使用 API 来完成,是的,速度很慢,但对于一定级别的 SKU 计数,它会及时工作。

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.

ま昔日黯然 2024-10-27 04:29:34

图层导航包含在类别视图中。
您应该包括按类别使用的导航部分,因此请尝试

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

在我不确定之前

<reference name="content">

插入,但如果它不起作用,它应该可以帮助您理解问题

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

独﹏钓一江月 2024-10-27 04:29:34

检查以下页面(他们遇到了同样的问题)

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文