Magento get product collection via custom observer -
i have custom observer in magento 1.8.1.0 called on product view page when current product having upsell products. have verified (using mage::log()) observer working, when try following:
public function updateupsells(varien_event_observer $oobserver) { $icurrentcategory = mage::registry('current_category')->getid(); $oupsellcollection = $oobserver->getcollection(); foreach ($oupsellcollection->getitems() $key => $oupsellproduct) { $acategoriesids = $oupsellproduct->getcategoryids(); if (!in_array($icurrentcategory, $acategoriesids)) { $oupsellcollection->removeitembykey($key); } } }
on echo $oupsellcollection;
got nothing returned ?
is know how upsell products collection ? proper way ?
$upsellcollection = $_product->getupsellproductcollection();
Comments
Post a Comment