【问题标题】:how to show particular category products on home page when clicked on it with magento?使用magento单击主页时如何在主页上显示特定类别的产品?
【发布时间】:2014-05-05 17:18:42
【问题描述】:

我必须在主页上显示五个类别的产品。当我单击特定类别时,该特定类别的产品将仅显示在主页上。当我单击任何其他类别时,该特定类别的产品将显示在主页上。 为此,我在Admin->Cms->Home Page->Content 中添加了以下代码,即

{{block type="catalog/product_list" category_id="4" template="catalog/product/new-arrival.phtml"}}

{{block type="catalog/product_list" category_id="5" template="catalog/product/featured-product.phtml"}}

{{block type="catalog/product_list" category_id="3" template="catalog/product/specials-product.phtml"}}

 {{block type="catalog/product_list" category_id="6" template="catalog/product/bestseller-product.phtml"}}

 {{block type="catalog/product_list" category_id="7" template="catalog/product/mostviewed-product.phtml"}}

我还在app/design/frontend/default/mytheme/catalog/product/做了五个不同的页面

但是所有五个类别的产品都显示在主页上,但我希望当我单击特定类别时,适当的类别产品将显示在主页上。主页的设计是1 column。 如果有人知道这一点,请帮助我。 谢谢!

【问题讨论】:

    标签: magento


    【解决方案1】:

    你可以试试这个代码

    只需创建一个产品列表页面并在其中添加以下代码。

      $_currentCategory = Mage::getModel('catalog/category')->load(Mage::registry('current_category')->getId()); 
    
    $_productCollection = Mage::getResourceModel('catalog/product_collection')
        ->addStoreFilter()
        ->addCategoryFilter($_currentCategory); 
    

    它将给出所有当前类别的产品。

    【讨论】:

    • 我已经制作了 5 个不同的页面来展示 5 个不同类别的产品......所以我没有得到你。你能详细说明一下
    • 所以基本上你希望当客户点击一个类别时,它会反映在主页上的所有类别产品上?
    • 是的,当我点击一个类别时,它只会显示该类别的产品
    最近更新 更多