Mage_GoogleBase_Model_Observer Class Reference

List of all members.

Public Member Functions

 saveProductItem ($observer)
 deleteProductItem ($observer)


Detailed Description

Definition at line 34 of file Observer.php.


Member Function Documentation

deleteProductItem ( observer  ) 

Delete product item from Google Base

Parameters:
Varien_Object $observer
Returns:
Mage_GoogleBase_Model_Observer

Definition at line 75 of file Observer.php.

00076     {
00077         try {
00078             $product = $observer->getEvent()->getProduct();
00079             if (Mage::getStoreConfigFlag('google/googlebase/observed', $product->getStoreId())) {
00080                 $collection = Mage::getResourceModel('googlebase/item_collection')
00081                     ->addProductFilterId($product->getId())
00082                     ->load();
00083                 foreach ($collection as $item) {
00084                     $item->deleteItem()->delete();
00085                 }
00086             }
00087         } catch (Exception $e) {
00088             if (Mage::app()->getStore()->isAdmin()) {
00089                 Mage::getSingleton('adminhtml/session')->addNotice(
00090                     Mage::helper('googlebase')->__("Cannot update Google Base Item for Store '%s'", Mage::app()->getStore($item->getStoreId())->getName())
00091                 );
00092             } else {
00093                 throw $e;
00094             }
00095         }
00096         return $this;
00097     }

saveProductItem ( observer  ) 

Update product item in Google Base

Parameters:
Varien_Object $observer
Returns:
Mage_GoogleBase_Model_Observer

Definition at line 42 of file Observer.php.

00043     {
00044         try {
00045             $product = $observer->getEvent()->getProduct();
00046             if (Mage::getStoreConfigFlag('google/googlebase/observed', $product->getStoreId())) {
00047                 $collection = Mage::getResourceModel('googlebase/item_collection')
00048                     ->addProductFilterId($product->getId())
00049                     ->load();
00050                 foreach ($collection as $item) {
00051                     $product = Mage::getSingleton('catalog/product')
00052                         ->setStoreId($item->getStoreId())
00053                         ->load($item->getProductId());
00054                     Mage::getModel('googlebase/item')->setProduct($product)->updateItem();
00055                 }
00056             }
00057         } catch (Exception $e) {
00058             if (Mage::app()->getStore()->isAdmin()) {
00059                 Mage::getSingleton('adminhtml/session')->addNotice(
00060                     Mage::helper('googlebase')->__("Cannot update Google Base Item for Store '%s'", Mage::app()->getStore($item->getStoreId())->getName())
00061                 );
00062             } else {
00063                 throw $e;
00064             }
00065         }
00066         return $this;
00067     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:15 2009 for Magento by  doxygen 1.5.8