@@ -59,8 +59,11 @@ class DataLayer extends DataObject {
59
59
60
60
61
61
/**
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
64
67
*/
65
68
public function __construct (
66
69
\Magento \Framework \App \Action \Context $ context ,
@@ -100,7 +103,7 @@ public function getVariables() {
100
103
* Add Variables
101
104
* @param string $name
102
105
* @param mix $value
103
- * @return MagePal\GoogleTagManager\Model\DataLayer
106
+ * @return \ MagePal\GoogleTagManager\Model\DataLayer
104
107
*/
105
108
public function addVariable ($ name , $ value ) {
106
109
@@ -119,13 +122,13 @@ protected function setCategoryDataLayer() {
119
122
if ($ this ->fullActionName === 'catalog_category_view '
120
123
&& $ _category = $ this ->_coreRegistry ->registry ('current_category ' )
121
124
) {
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 ' );
129
132
}
130
133
131
134
return $ this ;
@@ -141,11 +144,12 @@ protected function setProductDataLayer() {
141
144
) {
142
145
$ this ->addVariable ('list ' , 'detail ' );
143
146
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
+
149
153
$ this ->addVariable ('product ' , $ product );
150
154
}
151
155
@@ -161,7 +165,6 @@ protected function setCustomerDataLayer() {
161
165
$ customer ['isLoggedIn ' ] = true ;
162
166
$ customer ['id ' ] = $ this ->_customerSession ->getCustomerId ();
163
167
$ customer ['groupId ' ] = $ this ->_customerSession ->getCustomerGroupId ();
164
- //$customer['groupCode'] = ;
165
168
} else {
166
169
$ customer ['isLoggedIn ' ] = false ;
167
170
}
@@ -193,7 +196,7 @@ protected function setCartDataLayer() {
193
196
'sku ' => $ item ->getSku (),
194
197
'name ' => $ item ->getName (),
195
198
'price ' => $ item ->getPrice (),
196
- 'quantity ' => $ item ->getQty ()
199
+ 'quantity ' => $ item ->getQty (),
197
200
];
198
201
}
199
202
0 commit comments