Public Member Functions | |
setStoreId ($storeId) | |
getStoreId () | |
isOptimizerActive ($store=null) | |
isOptimizerActiveForCms () | |
productAttribute ($callObject, $attributeHtml, $params) | |
categoryAttribute ($callObject, $attributeHtml, $params) | |
getConversionPagesUrl () | |
Public Attributes | |
const | XML_PATH_ENABLED = 'google/optimizer/active' |
const | XML_PATH_ALLOWED_ATTRIBUTES = 'admin/attributes' |
const | MAX_ATTRIBUTE_LENGTH_LIMIT = 25 |
Protected Attributes | |
$_storeId = null | |
$_activeForCmsFlag = null |
Definition at line 34 of file Data.php.
categoryAttribute | ( | $ | callObject, | |
$ | attributeHtml, | |||
$ | params | |||
) |
Prepare category attribute html output
unknown_type | $callObject | |
unknown_type | $attributeHtml | |
unknown_type | $params |
Definition at line 124 of file Data.php.
00125 { 00126 $attributeName = $params['attribute']; 00127 $category = $params['category']; 00128 00129 if (!$this->isOptimizerActive($category->getStoreId()) 00130 || !$category->getGoogleOptimizerScripts() 00131 || !$category->getGoogleOptimizerScripts()->getControlScript()) { 00132 return $attributeHtml; 00133 } 00134 00135 $newAttributeName = 'category_'.$attributeName.'_'.$category->getId(); 00136 if (strlen($newAttributeName) > self::MAX_ATTRIBUTE_LENGTH_LIMIT) { 00137 $newAttributeName = 'category_'; 00138 $newAttributeName .= substr($attributeName, 0, (self::MAX_ATTRIBUTE_LENGTH_LIMIT - strlen('category__'.$category->getId()))); 00139 $newAttributeName .= '_'.$category->getId(); 00140 } 00141 00142 $attributeHtml = '<script>utmx_section("'.$newAttributeName.'")</script>' . $attributeHtml . '</noscript>'; 00143 return $attributeHtml; 00144 }
getConversionPagesUrl | ( | ) |
Return conversion pages from source model
Example:
array( 'checkout_cart' => 'http://base.url/...' )
Definition at line 151 of file Data.php.
00152 { 00153 /** 00154 * Example: 00155 * 00156 * array( 00157 * 'checkout_cart' => 'http://base.url/...' 00158 * ) 00159 */ 00160 $urls = array(); 00161 $choices = Mage::getModel('googleoptimizer/adminhtml_system_config_source_googleoptimizer_conversionpages') 00162 ->toOptionArray(); 00163 $url = Mage::getModel('core/url'); 00164 $session = Mage::getSingleton('core/session')->setSkipSessionIdFlag(true); 00165 $store = Mage::app()->getStore($this->getStoreId()); 00166 foreach ($choices as $choice) { 00167 $route = ''; 00168 switch ($choice['value']) { 00169 case 'checkout_cart': 00170 $route = 'checkout/cart'; 00171 break; 00172 case 'checkout_onepage': 00173 $route = 'checkout/onepage'; 00174 break; 00175 case 'checkout_multishipping': 00176 $route = 'checkout/multishipping'; 00177 break; 00178 case 'checkout_onepage_success': 00179 $route = 'checkout/onepage/success/'; 00180 break; 00181 case 'checkout_multishipping_success': 00182 $route = 'checkout/multishipping/success/'; 00183 break; 00184 case 'customer_account_create': 00185 $route = 'customer/account/create/'; 00186 break; 00187 } 00188 if ($route) { 00189 $_query = array(); 00190 $_path = Mage_Core_Model_Url::XML_PATH_UNSECURE_URL; 00191 if (Mage::getConfig()->shouldUrlBeSecure('/' . $route)) { 00192 $_path = Mage_Core_Model_Url::XML_PATH_SECURE_URL; 00193 } 00194 $storeBaseUrl = $store->getConfig($_path); 00195 $websiteBaseUrl = $store->getWebsite()->getConfig($_path); 00196 $defaultBaseUrl = Mage::app()->getStore(0)->getConfig($_path); 00197 if ($storeBaseUrl == $websiteBaseUrl && !Mage::app()->isSingleStoreMode()) { 00198 $_query = array('__store' => $store->getCode()); 00199 } 00200 $urls[$choice['value']] = $url->setStore($this->getStoreId())->getUrl($route, array('_secure' => true, '_query' => $_query)); 00201 } 00202 } 00203 $session->setSkipSessionIdFlag(false); 00204 return new Varien_Object($urls); 00205 }
getStoreId | ( | ) |
isOptimizerActive | ( | $ | store = null |
) |
Definition at line 56 of file Data.php.
00057 { 00058 return Mage::getStoreConfig(self::XML_PATH_ENABLED, $store); 00059 }
isOptimizerActiveForCms | ( | ) |
Return is active google optimizer for cms. Return true if optimizer is enabled only for one store|website.
Definition at line 67 of file Data.php.
00068 { 00069 if (!is_null($this->_activeForCmsFlag)) { 00070 return $this->_activeForCmsFlag; 00071 } 00072 $stores = array_merge( 00073 array(0), 00074 array_keys(Mage::getSingleton('adminhtml/system_store')->getStoreCollection()) 00075 ); 00076 foreach ($stores as $store) { 00077 if ($this->isOptimizerActive($store)) { 00078 $this->_activeForCmsFlag = true; 00079 return $this->_activeForCmsFlag; 00080 } 00081 } 00082 $this->_activeForCmsFlag = false; 00083 return $this->_activeForCmsFlag; 00084 }
productAttribute | ( | $ | callObject, | |
$ | attributeHtml, | |||
$ | params | |||
) |
Prepare product attribute html output
unknown_type | $callObject | |
unknown_type | $attributeHtml | |
unknown_type | $params |
Definition at line 94 of file Data.php.
00095 { 00096 $attributeName = $params['attribute']; 00097 $product = $params['product']; 00098 00099 if (!$this->isOptimizerActive($product->getStoreId()) 00100 || !$product->getGoogleOptimizerScripts() 00101 || !$product->getGoogleOptimizerScripts()->getControlScript()) { 00102 return $attributeHtml; 00103 } 00104 if (in_array($attributeName, $product->getGoogleOptimizerScripts()->getAttributes())) { 00105 $newAttributeName = 'product_'.$attributeName.'_'.$product->getId(); 00106 if (strlen($newAttributeName) > self::MAX_ATTRIBUTE_LENGTH_LIMIT) { 00107 $newAttributeName = 'product_'; 00108 $newAttributeName .= substr($attributeName, 0, (self::MAX_ATTRIBUTE_LENGTH_LIMIT - strlen('product__'.$product->getId()))); 00109 $newAttributeName .= '_'.$product->getId(); 00110 } 00111 $attributeHtml = '<script>utmx_section("'.$newAttributeName.'")</script>' . $attributeHtml . '</noscript>'; 00112 } 00113 return $attributeHtml; 00114 }
setStoreId | ( | $ | storeId | ) |
const MAX_ATTRIBUTE_LENGTH_LIMIT = 25 |
const XML_PATH_ALLOWED_ATTRIBUTES = 'admin/attributes' |
const XML_PATH_ENABLED = 'google/optimizer/active' |