Version Notes
No notes
Download this release
Release Info
Developer | Yireo |
Extension | yireo_googletagmanager |
Version | 1.3.12 |
Comparing to | |
See all releases |
Code changes from version 1.3.10 to 1.3.12
- app/code/community/Yireo/GoogleTagManager/Block/Category.php +8 -0
- app/code/community/Yireo/GoogleTagManager/Block/Default.php +22 -0
- app/code/community/Yireo/GoogleTagManager/Helper/Data.php +56 -37
- app/code/community/Yireo/GoogleTagManager/etc/config.xml +1 -1
- app/design/frontend/base/default/layout/googletagmanager.xml +1 -0
- package.xml +1 -1
app/code/community/Yireo/GoogleTagManager/Block/Category.php
CHANGED
@@ -32,6 +32,14 @@ class Yireo_GoogleTagManager_Block_Category extends Yireo_GoogleTagManager_Block
|
|
32 |
return $collection;
|
33 |
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
/**
|
36 |
* Return the current page limit, as set by the toolbar block
|
37 |
*
|
32 |
return $collection;
|
33 |
}
|
34 |
|
35 |
+
/**
|
36 |
+
* @param Mage_Catalog_Model_Category $category
|
37 |
+
*/
|
38 |
+
public function setCategory(Mage_Catalog_Model_Category $category)
|
39 |
+
{
|
40 |
+
$this->category = $category;
|
41 |
+
}
|
42 |
+
|
43 |
/**
|
44 |
* Return the current page limit, as set by the toolbar block
|
45 |
*
|
app/code/community/Yireo/GoogleTagManager/Block/Default.php
CHANGED
@@ -145,4 +145,26 @@ class Yireo_GoogleTagManager_Block_Default extends Mage_Core_Block_Template
|
|
145 |
$string = str_replace('"', "'", $string);
|
146 |
return $string;
|
147 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
145 |
$string = str_replace('"', "'", $string);
|
146 |
return $string;
|
147 |
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* @param $childScript
|
151 |
+
*/
|
152 |
+
public function setChildScript($childScript)
|
153 |
+
{
|
154 |
+
$this->childScript = $childScript;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @return string
|
159 |
+
*/
|
160 |
+
public function _toHtml()
|
161 |
+
{
|
162 |
+
// Bypass a bug that causes an empty HTML block to be skipped
|
163 |
+
$html = parent::_toHtml();
|
164 |
+
if (empty($html)) {
|
165 |
+
$html = ' ';
|
166 |
+
}
|
167 |
+
|
168 |
+
return $html;
|
169 |
+
}
|
170 |
}
|
app/code/community/Yireo/GoogleTagManager/Helper/Data.php
CHANGED
@@ -35,7 +35,7 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
35 |
*/
|
36 |
public function isEnabled()
|
37 |
{
|
38 |
-
if ((bool)
|
39 |
return false;
|
40 |
}
|
41 |
|
@@ -134,22 +134,25 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
134 |
*/
|
135 |
public function fetchBlock($name, $type, $template)
|
136 |
{
|
|
|
137 |
if (!($layout = Mage::app()->getFrontController()->getAction()->getLayout())) {
|
138 |
return false;
|
139 |
}
|
140 |
|
|
|
141 |
if ($block = $layout->getBlock('googletagmanager_' . $name)) {
|
142 |
$block->setTemplate('googletagmanager/' . $template);
|
143 |
-
$this->debug('Helper: Loading block from layout: '
|
144 |
return $block;
|
145 |
}
|
146 |
|
147 |
-
if ($block = $layout->createBlock('googletagmanager/' . $type)
|
148 |
-
$
|
|
|
149 |
return $block;
|
150 |
}
|
151 |
|
152 |
-
$this->debug('Helper: Unknown block: '
|
153 |
return false;
|
154 |
}
|
155 |
|
@@ -168,29 +171,29 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
168 |
}
|
169 |
|
170 |
// Add customer-information
|
171 |
-
$this->
|
172 |
|
173 |
// Add product-information
|
174 |
-
$this->
|
175 |
|
176 |
// Add category-information
|
177 |
-
$this->
|
178 |
|
179 |
// Add order-information
|
180 |
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
181 |
if (!empty($lastOrderId)) {
|
182 |
-
$this->
|
183 |
|
184 |
// Add quote-information
|
185 |
} else {
|
186 |
-
$this->
|
187 |
}
|
188 |
|
189 |
// Add custom information
|
190 |
-
$this->
|
191 |
|
192 |
// Add enhanced ecommerce-information
|
193 |
-
$this->
|
194 |
|
195 |
$block->setChildScript($childScript);
|
196 |
$html = $block->toHtml();
|
@@ -199,9 +202,9 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
199 |
}
|
200 |
|
201 |
/**
|
202 |
-
* @
|
203 |
*/
|
204 |
-
public function
|
205 |
{
|
206 |
$customer = Mage::getSingleton('customer/session');
|
207 |
if (!empty($customer)) {
|
@@ -211,15 +214,16 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
211 |
$customerBlock->setCustomer($customer);
|
212 |
$customerGroup = Mage::getSingleton('customer/group')->load($customer->getCustomerGroupId());
|
213 |
$customerBlock->setCustomerGroup($customerGroup);
|
214 |
-
$
|
|
|
215 |
}
|
216 |
}
|
217 |
}
|
218 |
|
219 |
/**
|
220 |
-
* @
|
221 |
*/
|
222 |
-
public function
|
223 |
{
|
224 |
$currentProduct = Mage::registry('current_product');
|
225 |
if (!empty($currentProduct)) {
|
@@ -227,31 +231,32 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
227 |
|
228 |
if ($productBlock) {
|
229 |
$productBlock->setProduct($currentProduct);
|
230 |
-
$
|
|
|
231 |
}
|
232 |
}
|
233 |
}
|
234 |
|
235 |
/**
|
236 |
-
* @
|
237 |
*/
|
238 |
-
public function
|
239 |
{
|
240 |
$currentCategory = Mage::registry('current_category');
|
241 |
if (!empty($currentCategory)) {
|
242 |
$categoryBlock = $this->fetchBlock('category', 'category', 'category.phtml');
|
243 |
-
|
244 |
if ($categoryBlock) {
|
245 |
$categoryBlock->setCategory($currentCategory);
|
246 |
-
$
|
|
|
247 |
}
|
248 |
}
|
249 |
}
|
250 |
|
251 |
/**
|
252 |
-
* @
|
253 |
*/
|
254 |
-
public function
|
255 |
{
|
256 |
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
257 |
|
@@ -261,15 +266,16 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
261 |
|
262 |
if ($orderBlock) {
|
263 |
$orderBlock->setOrder($order);
|
264 |
-
$
|
|
|
265 |
}
|
266 |
}
|
267 |
}
|
268 |
|
269 |
/**
|
270 |
-
* @
|
271 |
*/
|
272 |
-
public function
|
273 |
{
|
274 |
/** @var Mage_Sales_Model_Quote $quote */
|
275 |
$quote = Mage::getModel('checkout/cart')->getQuote();
|
@@ -279,15 +285,16 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
279 |
|
280 |
if ($quoteBlock) {
|
281 |
$quoteBlock->setQuote($quote);
|
282 |
-
$
|
|
|
283 |
}
|
284 |
}
|
285 |
}
|
286 |
|
287 |
/**
|
288 |
-
* @
|
289 |
*/
|
290 |
-
public function
|
291 |
{
|
292 |
$ecommerce = $this->getEcommerceData();
|
293 |
|
@@ -296,20 +303,22 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
296 |
|
297 |
if ($ecommerceBlock) {
|
298 |
$ecommerceBlock->setData('ecommerce', $ecommerce);
|
299 |
-
$
|
|
|
300 |
}
|
301 |
}
|
302 |
}
|
303 |
|
304 |
/**
|
305 |
-
* @
|
306 |
*/
|
307 |
-
public function
|
308 |
{
|
309 |
$customBlock = $this->fetchBlock('custom', 'custom', 'custom.phtml');
|
310 |
|
311 |
if ($customBlock) {
|
312 |
-
$
|
|
|
313 |
}
|
314 |
}
|
315 |
|
@@ -346,7 +355,7 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
346 |
}
|
347 |
|
348 |
if ($addJsEvent && !empty($html)) {
|
349 |
-
$html = 'onclick="'
|
350 |
}
|
351 |
|
352 |
return $html;
|
@@ -362,7 +371,7 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
362 |
}
|
363 |
|
364 |
if ($addJsEvent && !empty($html)) {
|
365 |
-
$html = 'onclick="'
|
366 |
}
|
367 |
|
368 |
return $html;
|
@@ -378,7 +387,7 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
378 |
}
|
379 |
|
380 |
if ($addJsEvent && !empty($html)) {
|
381 |
-
$html = 'onclick="'
|
382 |
}
|
383 |
|
384 |
return $html;
|
@@ -393,4 +402,14 @@ class Yireo_GoogleTagManager_Helper_Data extends Mage_Core_Helper_Abstract
|
|
393 |
{
|
394 |
return Mage::app()->getStore()->getCurrentCurrencyCode();
|
395 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
}
|
35 |
*/
|
36 |
public function isEnabled()
|
37 |
{
|
38 |
+
if ((bool)Mage::getStoreConfig('advanced/modules_disable_output/Yireo_GoogleTagManager')) {
|
39 |
return false;
|
40 |
}
|
41 |
|
134 |
*/
|
135 |
public function fetchBlock($name, $type, $template)
|
136 |
{
|
137 |
+
/** @var Mage_Core_Model_Layout $layout */
|
138 |
if (!($layout = Mage::app()->getFrontController()->getAction()->getLayout())) {
|
139 |
return false;
|
140 |
}
|
141 |
|
142 |
+
/** @var Mage_Core_Block_Template $block */
|
143 |
if ($block = $layout->getBlock('googletagmanager_' . $name)) {
|
144 |
$block->setTemplate('googletagmanager/' . $template);
|
145 |
+
$this->debug('Helper: Loading block from layout: ' . $name);
|
146 |
return $block;
|
147 |
}
|
148 |
|
149 |
+
if ($block = $layout->createBlock('googletagmanager/' . $type)) {
|
150 |
+
$block->setTemplate('googletagmanager/' . $template);
|
151 |
+
$this->debug('Helper: Creating new block: ' . $type);
|
152 |
return $block;
|
153 |
}
|
154 |
|
155 |
+
$this->debug('Helper: Unknown block: ' . $name);
|
156 |
return false;
|
157 |
}
|
158 |
|
171 |
}
|
172 |
|
173 |
// Add customer-information
|
174 |
+
$childScript .= $this->getCustomerScript();
|
175 |
|
176 |
// Add product-information
|
177 |
+
$childScript .= $this->getProductScript();
|
178 |
|
179 |
// Add category-information
|
180 |
+
$childScript .= $this->getCategoryScript();
|
181 |
|
182 |
// Add order-information
|
183 |
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
184 |
if (!empty($lastOrderId)) {
|
185 |
+
$childScript .= $this->getOrderScript();
|
186 |
|
187 |
// Add quote-information
|
188 |
} else {
|
189 |
+
$childScript .= $this->getQuoteScript();
|
190 |
}
|
191 |
|
192 |
// Add custom information
|
193 |
+
$childScript .= $this->getCustomScript();
|
194 |
|
195 |
// Add enhanced ecommerce-information
|
196 |
+
$childScript .= $this->getEcommerceScript();
|
197 |
|
198 |
$block->setChildScript($childScript);
|
199 |
$html = $block->toHtml();
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
+
* @return string
|
206 |
*/
|
207 |
+
public function getCustomerScript()
|
208 |
{
|
209 |
$customer = Mage::getSingleton('customer/session');
|
210 |
if (!empty($customer)) {
|
214 |
$customerBlock->setCustomer($customer);
|
215 |
$customerGroup = Mage::getSingleton('customer/group')->load($customer->getCustomerGroupId());
|
216 |
$customerBlock->setCustomerGroup($customerGroup);
|
217 |
+
$html = $customerBlock->toHtml();
|
218 |
+
return $html;
|
219 |
}
|
220 |
}
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
+
* @return string
|
225 |
*/
|
226 |
+
public function getProductScript()
|
227 |
{
|
228 |
$currentProduct = Mage::registry('current_product');
|
229 |
if (!empty($currentProduct)) {
|
231 |
|
232 |
if ($productBlock) {
|
233 |
$productBlock->setProduct($currentProduct);
|
234 |
+
$html = $productBlock->toHtml();
|
235 |
+
return $html;
|
236 |
}
|
237 |
}
|
238 |
}
|
239 |
|
240 |
/**
|
241 |
+
* @return string
|
242 |
*/
|
243 |
+
public function getCategoryScript()
|
244 |
{
|
245 |
$currentCategory = Mage::registry('current_category');
|
246 |
if (!empty($currentCategory)) {
|
247 |
$categoryBlock = $this->fetchBlock('category', 'category', 'category.phtml');
|
|
|
248 |
if ($categoryBlock) {
|
249 |
$categoryBlock->setCategory($currentCategory);
|
250 |
+
$html = $categoryBlock->toHtml();
|
251 |
+
return $html;
|
252 |
}
|
253 |
}
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
+
* @return string
|
258 |
*/
|
259 |
+
public function getOrderScript()
|
260 |
{
|
261 |
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
262 |
|
266 |
|
267 |
if ($orderBlock) {
|
268 |
$orderBlock->setOrder($order);
|
269 |
+
$html = $orderBlock->toHtml();
|
270 |
+
return $html;
|
271 |
}
|
272 |
}
|
273 |
}
|
274 |
|
275 |
/**
|
276 |
+
* @return string
|
277 |
*/
|
278 |
+
public function getQuoteScript()
|
279 |
{
|
280 |
/** @var Mage_Sales_Model_Quote $quote */
|
281 |
$quote = Mage::getModel('checkout/cart')->getQuote();
|
285 |
|
286 |
if ($quoteBlock) {
|
287 |
$quoteBlock->setQuote($quote);
|
288 |
+
$html = $quoteBlock->toHtml();
|
289 |
+
return $html;
|
290 |
}
|
291 |
}
|
292 |
}
|
293 |
|
294 |
/**
|
295 |
+
* @return string
|
296 |
*/
|
297 |
+
public function getEcommerceScript()
|
298 |
{
|
299 |
$ecommerce = $this->getEcommerceData();
|
300 |
|
303 |
|
304 |
if ($ecommerceBlock) {
|
305 |
$ecommerceBlock->setData('ecommerce', $ecommerce);
|
306 |
+
$html = $ecommerceBlock->toHtml();
|
307 |
+
return $html;
|
308 |
}
|
309 |
}
|
310 |
}
|
311 |
|
312 |
/**
|
313 |
+
* @return string
|
314 |
*/
|
315 |
+
public function getCustomScript()
|
316 |
{
|
317 |
$customBlock = $this->fetchBlock('custom', 'custom', 'custom.phtml');
|
318 |
|
319 |
if ($customBlock) {
|
320 |
+
$html = $customBlock->toHtml();
|
321 |
+
return $html;
|
322 |
}
|
323 |
}
|
324 |
|
355 |
}
|
356 |
|
357 |
if ($addJsEvent && !empty($html)) {
|
358 |
+
$html = 'onclick="' . $html . '"';
|
359 |
}
|
360 |
|
361 |
return $html;
|
371 |
}
|
372 |
|
373 |
if ($addJsEvent && !empty($html)) {
|
374 |
+
$html = 'onclick="' . $html . '"';
|
375 |
}
|
376 |
|
377 |
return $html;
|
387 |
}
|
388 |
|
389 |
if ($addJsEvent && !empty($html)) {
|
390 |
+
$html = 'onclick="' . $html . '"';
|
391 |
}
|
392 |
|
393 |
return $html;
|
402 |
{
|
403 |
return Mage::app()->getStore()->getCurrentCurrencyCode();
|
404 |
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* @param $message
|
408 |
+
*/
|
409 |
+
public function writeLog($message)
|
410 |
+
{
|
411 |
+
if ((bool)$this->getConfigValue('debug', 0)) {
|
412 |
+
Mage::log('Yireo_GoogleTagManager: ' . $message);
|
413 |
+
}
|
414 |
+
}
|
415 |
}
|
app/code/community/Yireo/GoogleTagManager/etc/config.xml
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Yireo_GoogleTagManager>
|
15 |
-
<version>1.3.
|
16 |
</Yireo_GoogleTagManager>
|
17 |
</modules>
|
18 |
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Yireo_GoogleTagManager>
|
15 |
+
<version>1.3.12</version>
|
16 |
</Yireo_GoogleTagManager>
|
17 |
</modules>
|
18 |
|
app/design/frontend/base/default/layout/googletagmanager.xml
CHANGED
@@ -16,6 +16,7 @@
|
|
16 |
<block type="googletagmanager/quote" name="googletagmanager_quote" template="googletagmanager/quote.phtml" />
|
17 |
<block type="googletagmanager/product" name="googletagmanager_product" template="googletagmanager/product.phtml" />
|
18 |
<block type="googletagmanager/category" name="googletagmanager_category" template="googletagmanager/category.phtml" />
|
|
|
19 |
<block type="googletagmanager/custom" name="googletagmanager_custom" template="googletagmanager/custom.phtml" />
|
20 |
<block type="googletagmanager/default" name="googletagmanager" template="googletagmanager/default.phtml" />
|
21 |
<block type="googletagmanager/script" name="googletagmanager_script" template="googletagmanager/script.phtml" />
|
16 |
<block type="googletagmanager/quote" name="googletagmanager_quote" template="googletagmanager/quote.phtml" />
|
17 |
<block type="googletagmanager/product" name="googletagmanager_product" template="googletagmanager/product.phtml" />
|
18 |
<block type="googletagmanager/category" name="googletagmanager_category" template="googletagmanager/category.phtml" />
|
19 |
+
<block type="googletagmanager/ecommerce" name="googletagmanager_ecommerce" template="googletagmanager/ecommerce.phtml" />
|
20 |
<block type="googletagmanager/custom" name="googletagmanager_custom" template="googletagmanager/custom.phtml" />
|
21 |
<block type="googletagmanager/default" name="googletagmanager" template="googletagmanager/default.phtml" />
|
22 |
<block type="googletagmanager/script" name="googletagmanager_script" template="googletagmanager/script.phtml" />
|
package.xml
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
<package><name>yireo_googletagmanager</name><version>1.3.
|
1 |
<?xml version="1.0"?>
|
2 |
+
<package><name>yireo_googletagmanager</name><version>1.3.12</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2016-02-11</date><time>1:23:20</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_GoogleTagManager.xml" hash="420bde8207c2ed151e50ef4b7df1c28f"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="googletagmanager"><file name="category.phtml" hash="8ed9e3cadaa58ca7e41ad233736a112c"/><file name="custom.phtml" hash="b888cea900aba4a488968ca88a42813d"/><file name="customer.phtml" hash="3db76ba18473a1c7f664c1b50db622a4"/><file name="default.phtml" hash="b2247df055e48fc6ae8cb535e8ec9f52"/><file name="ecommerce.phtml" hash="da3bbe9f182ff24a62ad84d7d8c8b7bc"/><file name="order.phtml" hash="5dadb37be8798f76651e9bbb55a9bf4a"/><file name="product.phtml" hash="d7b8622019620c5609881924ab1657c0"/><file name="product_addtocart.phtml" hash="ead689aa81c78ac9bb182b96a6edbe90"/><file name="product_click.phtml" hash="1946b2edbcd2295cc21031e72293f268"/><file name="product_removefromcart.phtml" hash="f743569a3c3e5aa3bf209b44fe4fcd51"/><file name="quote.phtml" hash="18c5352672c1b6ef704e60f8c3f035f2"/><file name="script.phtml" hash="9fc6143f2237988f1ff4325d5cfc0969"/></dir></dir><dir name="layout"><file name="googletagmanager.xml" hash="fec2a5570a9953e31657aa50bd334ee1"/></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="GoogleTagManager"><dir name="etc"><file name="config.xml" hash="17b293c4a269f92a4324cdfb59498147"/><file name="system.xml" hash="1a0483ed2cd30bd1ec806797a8624225"/></dir><dir name="Model"><file name="Container.php" hash="70873159e8eb2254b8f701bc7ccf313e"/><file name="Observer.php" hash="fd35c56d813aac90583321588b355a0b"/><dir name="Backend"><dir name="Source"><file name="Method.php" hash="8af7a0459aaa78c93bf8c2d11a1bd46c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2f94fc7a2a5197885ab75a1fcf7378c0"/></dir><dir name="Block"><file name="Category.php" hash="001bb9fed52b7307dcd211fd32ab72cb"/><file name="Custom.php" hash="e208f2669b99b54001d90730b1fa5e2f"/><file name="Customer.php" hash="b8c90683ce9860d530c1dfb16e15ecda"/><file name="Default.php" hash="c45054124d9f4a8887685f2811925261"/><file name="Ecommerce.php" hash="13bb03fab65e9afe756bc087ba328302"/><file name="Order.php" hash="eaaa92e54a6f98c8c39ee484dff1a7bb"/><file name="Product.php" hash="7427e6ff8ef6efa9acaac933a3e76b4a"/><file name="Quote.php" hash="d4ada2d05f420e396849780ad547c1dd"/><file name="Script.php" hash="efe492a317563bfe87772f678a338088"/></dir></dir></dir></dir></dir></dir></target></contents></package>
|