Skip to content

Commit 53c94f0

Browse files
committed
Issue #7 - Undefined variable: items
1 parent cb76d13 commit 53c94f0

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

Model/DataLayer.php

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ class DataLayer extends DataObject {
5959

6060

6161
/**
62-
* @param MessageInterface $message
63-
* @param null $parameters
62+
* @param \Magento\Framework\App\Action\Context $context
63+
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
64+
* @param \Magento\Customer\Model\Session $customerSession
65+
* @param \Magento\Checkout\Model\Session $checkoutSession
66+
* @param \Magento\Framework\Registry $registry
6467
*/
6568
public function __construct(
6669
\Magento\Framework\App\Action\Context $context,
@@ -100,7 +103,7 @@ public function getVariables() {
100103
* Add Variables
101104
* @param string $name
102105
* @param mix $value
103-
* @return MagePal\GoogleTagManager\Model\DataLayer
106+
* @return \MagePal\GoogleTagManager\Model\DataLayer
104107
*/
105108
public function addVariable($name, $value) {
106109

@@ -119,13 +122,13 @@ protected function setCategoryDataLayer() {
119122
if($this->fullActionName === 'catalog_category_view'
120123
&& $_category = $this->_coreRegistry->registry('current_category')
121124
) {
122-
$category = [];
123-
$category['id'] = $_category->getId();
124-
$category['name'] = $_category->getName();
125-
126-
$this->addVariable('category', $category);
127-
128-
$this->addVariable('list', 'category');
125+
$category = [
126+
'id' => $_category->getId(),
127+
'name' => $_category->getName(),
128+
];
129+
130+
$this->addVariable('category', $category);
131+
$this->addVariable('list', 'category');
129132
}
130133

131134
return $this;
@@ -141,11 +144,12 @@ protected function setProductDataLayer() {
141144
) {
142145
$this->addVariable('list', 'detail');
143146

144-
$product = [];
145-
$product['id'] = $_product->getId();
146-
$product['sku'] = $_product->getSku();
147-
$product['name'] = $_product->getName();
148-
// $this->addVariable('productPrice', $_product->getPrice());
147+
$product = [
148+
'id' => $_product->getId(),
149+
'sku' => $_product->getSku(),
150+
'name' => $_product->getName(),
151+
];
152+
149153
$this->addVariable('product', $product);
150154
}
151155

@@ -161,7 +165,6 @@ protected function setCustomerDataLayer() {
161165
$customer['isLoggedIn'] = true;
162166
$customer['id'] = $this->_customerSession->getCustomerId();
163167
$customer['groupId'] = $this->_customerSession->getCustomerGroupId();
164-
//$customer['groupCode'] = ;
165168
} else {
166169
$customer['isLoggedIn'] = false;
167170
}
@@ -193,7 +196,7 @@ protected function setCartDataLayer() {
193196
'sku' => $item->getSku(),
194197
'name' => $item->getName(),
195198
'price' => $item->getPrice(),
196-
'quantity' => $item->getQty()
199+
'quantity' => $item->getQty(),
197200
];
198201
}
199202

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"magento/framework": "100.0.*|100.1.*"
1717
},
1818
"type": "magento2-module",
19-
"version": "1.2.1",
19+
"version": "1.2.2",
2020
"license": [
2121
"OSL-3.0",
2222
"AFL-3.0"

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="MagePal_GoogleTagManager" setup_version="1.2.1">
3+
<module name="MagePal_GoogleTagManager" setup_version="1.2.2">
44
<sequence>
55
<module name="Magento_Store"/>
66
</sequence>

0 commit comments

Comments
 (0)