Public Member Functions | |
setEntity (Varien_Object $entity) | |
getEntity () | |
getEntityType () | |
loadScripts ($storeId) | |
saveScripts ($storeId) | |
deleteScripts ($storeId) | |
Protected Member Functions | |
_construct () | |
_validate () | |
Protected Attributes | |
$_entity = null | |
$_entityType = null | |
$_validateEntryFlag = false | |
$_scriptTypes = array('control', 'tracking', 'conversion') |
Definition at line 34 of file Code.php.
_construct | ( | ) | [protected] |
Enter description here...
Reimplemented from Varien_Object.
Definition at line 41 of file Code.php.
00042 { 00043 parent::_construct(); 00044 $this->_init('googleoptimizer/code'); 00045 }
_validate | ( | ) | [protected] |
Validate sctipts that assigned on entity
Reimplemented in Mage_GoogleOptimizer_Model_Code_Page, and Mage_GoogleOptimizer_Model_Code_Product.
Definition at line 105 of file Code.php.
00106 { 00107 $entryFlag = false; 00108 $validationResult = false; 00109 if ($control = $this->getControlScript()) { 00110 $entryFlag = true; 00111 } 00112 if ($tracking = $this->getTrackingScript()) { 00113 $entryFlag = true; 00114 } 00115 if ($conversion = $this->getConversionScript()) { 00116 $entryFlag = true; 00117 } 00118 if ($conversionPage = $this->getConversionPage()) { 00119 $entryFlag = true; 00120 } 00121 $this->_validateEntryFlag = $entryFlag; 00122 if ($entryFlag && (!$control || !$tracking || !$conversion || !$conversionPage)) { 00123 return false; 00124 } 00125 return true; 00126 }
deleteScripts | ( | $ | storeId | ) |
Removing scripts assigned to entity
integer | $storeId |
Reimplemented in Mage_GoogleOptimizer_Model_Code_Category.
Definition at line 175 of file Code.php.
00176 { 00177 if (is_null($this->getEntity()) || is_null($this->getEntityType())) { 00178 return $this; 00179 } 00180 $this->getResource()->deleteByEntityType($this, $storeId); 00181 return $this; 00182 }
getEntity | ( | ) |
getEntityType | ( | ) |
loadScripts | ( | $ | storeId | ) |
Loading scripts and assigning scripts on entity
Varien_Object | $entity |
Definition at line 85 of file Code.php.
00086 { 00087 if (is_null($this->getEntity()) || is_null($this->getEntityType())) { 00088 return $this; 00089 } 00090 00091 if (!$storeId) { 00092 $storeId = Mage::app()->getStore()->getId(); 00093 } 00094 00095 $this->getResource()->loadByEntityType($this, $storeId); 00096 $this->_afterLoad(); 00097 return $this; 00098 }
saveScripts | ( | $ | storeId | ) |
Save scripts assigned on entity
Varien_Object | $entity |
We can't modify store id if existing stcript
Definition at line 134 of file Code.php.
00135 { 00136 if (is_null($this->getEntity()) || is_null($this->getEntityType())) { 00137 return $this; 00138 } 00139 if (!$this->getEntity()->getGoogleOptimizerScripts()) { 00140 return $this; 00141 } 00142 $script = $this->getEntity()->getGoogleOptimizerScripts(); 00143 00144 $this->setData($script->getData()) 00145 ->setEntityId($this->getEntity()->getId()) 00146 ->setEntityType($this->getEntityType()); 00147 00148 /** 00149 * We can't modify store id if existing stcript 00150 */ 00151 if (!$script->getId()) { 00152 $this->setStoreId($storeId); 00153 } 00154 00155 if (false === $this->_validate()) { 00156 throw new Exception(Mage::helper('googleoptimizer')->__('All fields of script types have to be filled.')); 00157 } 00158 00159 // use default scripts, need to delete scripts for current store 00160 if ($this->getStoreFlag()) { 00161 $this->deleteScripts($storeId); 00162 return $this; 00163 } 00164 00165 $this->save(); 00166 return $this; 00167 }
setEntity | ( | Varien_Object $ | entity | ) |
Set entity
Varien_Object | $entity |
Definition at line 53 of file Code.php.
$_entityType = null [protected] |
$_scriptTypes = array('control', 'tracking', 'conversion') [protected] |