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工作這樣做是正確的,但我可能會使用索引表,將每個品牌與相關類別聯繫起來。乾杯! –