我在Magento 1.8.1.0中有一个自定义观察者,当当前产品具有任何UPSELL产品时,该观察者在产品视图页面上被调用。我已经验证了(使用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;
上,我什么也没返回吗?
有人知道如何获得Upsell产品收藏吗?这是一种正确的方法吗?
$upsellCollection = $_product->getUpSellProductCollection();