【发布时间】:2023-03-31 12:24:01
【问题描述】:
我在 Magento 1.8.1.0 中有一个自定义观察者,当当前产品有任何追加销售产品时,它会在产品视图页面上调用。我已经验证(使用 Mage::log())观察者正在工作,但是当我尝试以下操作时:
public function updateUpsells(Varien_Event_Observer $oObserver)
{
$iCurrentCategory = Mage::registry('current_category')->getId();
$oUpsellCollection = $oObserver->getCollection();
foreach ($oUpsellCollection->getItems() as $key => $oUpsellProduct) {
$aCategoriesIds = $oUpsellProduct->getCategoryIds();
if (!in_array($iCurrentCategory, $aCategoriesIds)) {
$oUpsellCollection->removeItemByKey($key);
}
}
}
在echo $oUpsellCollection; 上我没有任何回报?
有人知道如何获得追加销售产品系列吗?这是一个正确的方法吗?
【问题讨论】: