2
我花了一些时间试图找出这一点,但无济于事。如果我有一系列显示由制造商过滤的产品集合的页面,并且我希望在这些页面的每一页的左栏中都有一些导航,其中包含当前制造商提供的包含产品的类别列表,那么将如何我在不使用一些可怕的慢代码的情况下进行填充? (有几千种产品)。Magento - 获得所有类别的产品品牌
我可以在循环中加入与此类似的东西,遍历每个类别,查看是否有针对每个类别返回的制造商的任何结果,但考虑到有几百个类别,这会相当缓慢。
$category = $currentCategory;
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($category);
$attributes = $layer->getFilterableAttributes();
$manufacturers = array();
foreach ($attributes as $attribute) {
if ($attribute->getAttributeCode() == 'manufacturer') {
$filterBlockName = 'catalog/layer_filter_attribute';
$result = Mage::app()->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init();
foreach($result->getItems() as $option) {
$manufacturers[$option->getValue()] = $option->getLabel();
}
}
}
如果有人有任何更好的想法,我将非常感激。
谢谢你。你是对的,通过cron工作这样做是正确的,但我可能会使用索引表,将每个品牌与相关类别联系起来。干杯! –