*/ class Mage_GoogleBase_Model_Observer { /** * Update product item in Google Base * * @param Varien_Object $observer * @return Mage_GoogleBase_Model_Observer */ public function saveProductItem($observer) { try { $product = $observer->getEvent()->getProduct(); if (Mage::getStoreConfigFlag('google/googlebase/observed', $product->getStoreId())) { $collection = Mage::getResourceModel('googlebase/item_collection') ->addProductFilterId($product->getId()) ->load(); foreach ($collection as $item) { $product = Mage::getSingleton('catalog/product') ->setStoreId($item->getStoreId()) ->load($item->getProductId()); Mage::getModel('googlebase/item')->setProduct($product)->updateItem(); } } } catch (Exception $e) { if (Mage::app()->getStore()->isAdmin()) { Mage::getSingleton('adminhtml/session')->addNotice( Mage::helper('googlebase')->__("Cannot update Google Base Item for Store '%s'", Mage::app()->getStore($item->getStoreId())->getName()) ); } else { throw $e; } } return $this; } /** * Delete product item from Google Base * * @param Varien_Object $observer * @return Mage_GoogleBase_Model_Observer */ public function deleteProductItem($observer) { try { $product = $observer->getEvent()->getProduct(); if (Mage::getStoreConfigFlag('google/googlebase/observed', $product->getStoreId())) { $collection = Mage::getResourceModel('googlebase/item_collection') ->addProductFilterId($product->getId()) ->load(); foreach ($collection as $item) { $item->deleteItem()->delete(); } } } catch (Exception $e) { if (Mage::app()->getStore()->isAdmin()) { Mage::getSingleton('adminhtml/session')->addNotice( Mage::helper('googlebase')->__("Cannot update Google Base Item for Store '%s'", Mage::app()->getStore($item->getStoreId())->getName()) ); } else { throw $e; } } return $this; } }