我有许多网站使用与主网站相同的根类别。 添加的每个产品都会添加到它添加到的站点(哇。)以及主站点。 但是,我希望仅当该网站上有产品时才显示基于每个网站的类别。
如果我有:
Category1
Category2
Category3
但是Site1只有Category1和Category2的产品,而Site2和Site3有Category2和Category3的产品; 我只希望 Category1/2 出现在 Site1 上,而 Category2/3 只出现在 Site2 和 Site3 上。
但是,由于Site1/2/3中的所有产品也都添加到了主站点中; 主站点将列出类别 1/2/3。
没有产品直接添加到主站点。 它只是充当其他站点的存储库。
现在,如果没有真正简单的方法来启用此功能(正如我确信的那样),是否会像编写自己的主题一样简单,该主题列出了仅在显示模板的网站上包含产品的类别?
我对 Magento 使用的技术并不是新手; 所以编写自定义代码是没有问题的。 然而,我不想对其进行太多编辑,以便将来使用更高版本的 Magento 升级我的代码库会更容易。
谢谢,
-纳尔逊
I have many sites that use the same root category of the Main Site. Each product that is added is added to the site it was added to (wow.) and also the Main Site. However, I would like categories on a per site basis to only appear if there are products on that site.
If I have:
Category1
Category2
Category3
But Site1 only has products in Category1 and Category2, whereas Site2 and Site3 have products in Category2 and Category3; I only want Category1/2 to appear on Site1 and only Category2/3 to only appear on Site2 and Site3.
However, because all products in Site1/2/3 are also added to the Main Site; the Main Site would list Category1/2/3.
No products are added directly to the Main Site. It simply serves as a repository for the other sites.
Now, if there is no really easy way to enable this (as I'm sure), would it be as simple as writing my own theme that lists categories that only have products on the site that the template is being displayed on?
I am not a novice in the technologies that Magento uses; so writing custom code is no problem. I would, however, not like to edit it that much so that upgrading my code base would be easier in the future with later versions of Magento.
Thanks,
-nelson
发布评论
评论(2)
那么,您可以做的是,使用集合(通过模型)创建您自己的助手,然后根据产品计数过滤集合。
只是一个草稿,但我在另一个与magento相关的问题中发布了一些代码:Magento产品按类别。 您可以看到它如何以及何时添加产品计数,完成后我会再次过滤。
我不认为这在性能方面非常“出色”,因此您可以编写自己的模型类,扩展它并添加默认过滤器,或者直接快捷方式访问数据库,而不是使用它们的模型类。
只要您保留在皮肤/模板中,更新就不会有更大的问题。
Well, what you can do is, create your own helper with a collection (through a model), and then filter the collection based on product count.
Only a rough draft, but I've posted some code in another magento related question: Magento products by categories. You can see how and when it adds the products count, I'd filter again when this is done.
I don't think this is extremely "great" in terms of performance, so instead of using their model classes, you could write your own, extending it and adding default filters, or shortcutting directly to the database.
As long as you stay in your skin/template, there are no larger issues with updating.
这是隐藏可能对您有帮助的类别的简单解决方案。
top.phtml 文件的原始内容应如下所示。
将上面的代码替换为下面的代码。
this is a simple solution to hide categories that might help you .
The original contents of the top.phtml file should look like below.
Replace the code above with this code below.