Mage_GoogleOptimizer_Model_Observer Class Reference

List of all members.

Public Member Functions

 appendToProductGoogleOptimizerScripts ($observer)
 prepareGoogleOptimizerScripts ($observer)
 prepareProductGoogleOptimizerScripts ($observer)
 saveProductGoogleOptimizerScripts ($observer)
 deleteProductGoogleOptimizerScripts ($observer)
 appendToPageGoogleOptimizerScripts ($observer)
 preparePageGoogleOptimizerScripts ($observer)
 savePageGoogleOptimizerScripts ($observer)
 deletePageGoogleOptimizerScripts ($observer)
 assignHandlers ($observer)
 appendToCategoryGoogleOptimizerScripts ($observer)
 prepareCategoryGoogleOptimizerScripts ($observer)
 saveCategoryGoogleOptimizerScripts ($observer)
 deleteCategoryGoogleOptimizerScripts ($observer)


Detailed Description

Definition at line 34 of file Observer.php.


Member Function Documentation

appendToCategoryGoogleOptimizerScripts ( observer  ) 

Loading category scripts after load category

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 212 of file Observer.php.

00213     {
00214         $category = $observer->getEvent()->getCategory();
00215 
00216         if (!Mage::helper('googleoptimizer')->isOptimizerActive($category->getStoreId())) {
00217             return $this;
00218         }
00219 
00220         $googleOptimizerModel = Mage::getModel('googleoptimizer/code_category')
00221             ->setEntity($category)
00222             ->loadScripts($category->getStoreId());
00223         if ($googleOptimizerModel->getId()) {
00224             $category->setGoogleOptimizerScripts($googleOptimizerModel);
00225         }
00226         return $this;
00227     }

appendToPageGoogleOptimizerScripts ( observer  ) 

Loading page scripts after load page

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Check activity for frontend

Definition at line 126 of file Observer.php.

00127     {
00128         /**
00129          * Check activity for frontend
00130          */
00131         if (Mage::app()->getStore()->getId() && !Mage::helper('googleoptimizer')->isOptimizerActive()) {
00132             return $this;
00133         }
00134         
00135         $cmsPage = $observer->getEvent()->getObject();
00136         $googleOptimizerModel = Mage::getModel('googleoptimizer/code_page')
00137             ->setEntity($cmsPage)
00138             ->loadScripts(0);
00139 
00140         if ($googleOptimizerModel->getId()) {
00141             $cmsPage->setGoogleOptimizerScripts($googleOptimizerModel);
00142         }
00143         return $this;
00144     }

appendToProductGoogleOptimizerScripts ( observer  ) 

Loading product scripts after load product

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 42 of file Observer.php.

00043     {
00044         $product = $observer->getEvent()->getProduct();
00045 
00046         if (!Mage::helper('googleoptimizer')->isOptimizerActive($product->getStoreId())) {
00047             return $this;
00048         }
00049 
00050         $googleOptimizerModel = Mage::getModel('googleoptimizer/code_product')
00051             ->setEntity($product)
00052             ->loadScripts($product->getStoreId());
00053         if ($googleOptimizerModel->getId()) {
00054             $product->setGoogleOptimizerScripts($googleOptimizerModel);
00055         }
00056         return $this;
00057     }

assignHandlers ( observer  ) 

Definition at line 197 of file Observer.php.

00198     {
00199         $catalogHalper = $observer->getEvent()->getHelper();
00200         $helper = Mage::helper('googleoptimizer');
00201         $catalogHalper->addHandler('productAttribute', $helper)
00202             ->addHandler('categoryAttribute', $helper);
00203         return $this;
00204     }

deleteCategoryGoogleOptimizerScripts ( observer  ) 

Delete category scripts after deleting category

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 275 of file Observer.php.

00276     {
00277         $category = $observer->getEvent()->getCategory();
00278         $googleOptimizer = Mage::getModel('googleoptimizer/code_category')
00279             ->setEntity($category)
00280             ->deleteScripts($category->getStoreId());
00281         return $this;
00282     }

deletePageGoogleOptimizerScripts ( observer  ) 

Delete page scripts after deleting page

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 188 of file Observer.php.

00189     {
00190         $cmsPage = $observer->getEvent()->getObject();
00191         $googleOptimizer = Mage::getModel('googleoptimizer/code_page')
00192             ->setEntity($cmsPage)
00193             ->deleteScripts(0);
00194         return $this;
00195     }

deleteProductGoogleOptimizerScripts ( observer  ) 

Delete Produt scripts after deleting product

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 111 of file Observer.php.

00112     {
00113         $product = $observer->getEvent()->getProduct();
00114         $googleOptimizer = Mage::getModel('googleoptimizer/code_product')
00115             ->setEntity($product)
00116             ->deleteScripts($product->getStoreId());
00117         return $this;
00118     }

prepareCategoryGoogleOptimizerScripts ( observer  ) 

Prepare category scripts for saving

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 235 of file Observer.php.

00236     {
00237         $category = $observer->getEvent()->getCategory();
00238         $request = $observer->getEvent()->getRequest();
00239 
00240         if ($googleOptimizer = $request->getPost('googleoptimizer')) {
00241             $category->setGoogleOptimizerScripts(new Varien_Object($googleOptimizer));
00242         }
00243         return $this;
00244     }

prepareGoogleOptimizerScripts ( observer  ) 

Deprecated:
please use prepareProductGoogleOptimizerScripts method instead
Parameters:
Varien_Object $observer

Definition at line 64 of file Observer.php.

00065     {
00066         $this->prepareProductGoogleOptimizerScripts($observer);
00067     }

preparePageGoogleOptimizerScripts ( observer  ) 

Prepare page scripts for saving

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 152 of file Observer.php.

00153     {
00154         $cmsPage = $observer->getEvent()->getPage();
00155         $request = $observer->getEvent()->getRequest();
00156 
00157         if ($googleOptimizer = $request->getPost('googleoptimizer')) {
00158             $cmsPage->setGoogleOptimizerScripts(new Varien_Object($googleOptimizer));
00159         }
00160         return $this;
00161     }

prepareProductGoogleOptimizerScripts ( observer  ) 

Prepare product scripts for saving

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 75 of file Observer.php.

00076     {
00077         $product = $observer->getEvent()->getProduct();
00078         $request = $observer->getEvent()->getRequest();
00079 
00080         if ($googleOptimizer = $request->getPost('googleoptimizer')) {
00081             $product->setGoogleOptimizerScripts(new Varien_Object($googleOptimizer));
00082         }
00083         return $this;
00084     }

saveCategoryGoogleOptimizerScripts ( observer  ) 

Save category scripts after saving category

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 252 of file Observer.php.

00253     {
00254         $category = $observer->getEvent()->getCategory();
00255 
00256         if (!Mage::helper('googleoptimizer')->isOptimizerActive($category->getStoreId())) {
00257             return $this;
00258         }
00259 
00260         if ($category->getGoogleOptimizerScripts()) {
00261             $googleOptimizer = Mage::getModel('googleoptimizer/code_category')
00262                 ->setEntity($category)
00263                 ->saveScripts($category->getStoreId());
00264         }
00265 
00266         return $this;
00267     }

savePageGoogleOptimizerScripts ( observer  ) 

Save page scripts after saving page

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 169 of file Observer.php.

00170     {
00171         $cmsPage = $observer->getEvent()->getObject();
00172 
00173         if ($cmsPage->getGoogleOptimizerScripts()) {
00174             $googleOptimizer = Mage::getModel('googleoptimizer/code_page')
00175                 ->setEntity($cmsPage)
00176                 ->saveScripts(0);
00177         }
00178 
00179         return $this;
00180     }

saveProductGoogleOptimizerScripts ( observer  ) 

Save product scripts after saving product

Parameters:
Varien_Object $observer
Returns:
Mage_Googleoptimizer_Model_Observer

Definition at line 92 of file Observer.php.

00093     {
00094         $product = $observer->getEvent()->getProduct();
00095 
00096         if ($product->getGoogleOptimizerScripts()) {
00097             $googleOptimizer = Mage::getModel('googleoptimizer/code_product')
00098                 ->setEntity($product)
00099                 ->saveScripts($product->getStoreId());
00100         }
00101 
00102         return $this;
00103     }


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

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