Magento通过自定义观察者获取产品集合

Magento通过自定义观察者获取产品集合,magento,product,observers,Magento,Product,Observers,我在Magento 1.8.1.0中有一个自定义的观察者,当当前产品有任何追加销售的产品时,它会在产品视图页面上调用。我已经使用Mage::log验证了观察者是否正常工作,但是当我尝试以下操作时: public function updateUpsells(Varien_Event_Observer $oObserver) { $iCurrentCategory = Mage::registry('current_category')->getId(); $oUpsellC

我在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$s收集;我什么也没得到

有人知道如何获得upsell产品系列吗?这样做合适吗

$upsellCollection = $_product->getUpSellProductCollection();