Magento: Display products from childcategories if parent category is empty

泪湿孤枕 提交于 2019-12-08 19:03:45

问题


I have the following categories

Car parts (0) Tires (0) Rims (5)

Now in the product listing obviously the car parts en tires listing returns 0 products. But for the user this is ankward. Is it possible to show child items if a category is empty?

Kind regards


回答1:


Have you marked the category as an anchor category in the administrative interface? That should allow child categories' products to show up in the parent category listing.

Hope that helps.

Thanks, Joe




回答2:


I've been looking for hours for an answer to this myself, and finally found the solution.

As many sites and questions give the solution "set the parent category to 'is anchor=yes' or 'try re-indexing your products', you might find that neither of these work. However, you need to combine these:

1. First, set the categories of which you want to show its sub-categories' products, to 'is anchor -> Yes'. (Catalog > Manage categories' in admin) You will now see that this category has the number of products all the sub-categories together contain.

2. To show this on your website, you have to reindex the data now. In admin, go to System > Index Management and tick the 'Category products' checkbox. Hit 'send' and it'll reindex.

Voilà, your products show where you want them to show. One downside is that the page will now also show 'layered navigation', but if you don't want this you can simply set the div that contains this to display:none in CSS.

We owe it all to this site where I found it: http://sheldonrcohen.com/Blog/tabid/88/EntryId/12/Magento-parent-category-not-showing-sub-category-products.aspx

Thanks Sheldon Cohen! :)



来源:https://stackoverflow.com/questions/2272736/magento-display-products-from-childcategories-if-parent-category-is-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!