Skip to content

Commit

Permalink
Issue #7 - Undefined variable: items
Browse files Browse the repository at this point in the history
  • Loading branch information
srenon committed Jan 16, 2017
1 parent cb76d13 commit 53c94f0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
37 changes: 20 additions & 17 deletions Model/DataLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ class DataLayer extends DataObject {


/**
* @param MessageInterface $message
* @param null $parameters
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\Registry $registry
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
Expand Down Expand Up @@ -100,7 +103,7 @@ public function getVariables() {
* Add Variables
* @param string $name
* @param mix $value
* @return MagePal\GoogleTagManager\Model\DataLayer
* @return \MagePal\GoogleTagManager\Model\DataLayer
*/
public function addVariable($name, $value) {

Expand All @@ -119,13 +122,13 @@ protected function setCategoryDataLayer() {
if($this->fullActionName === 'catalog_category_view'
&& $_category = $this->_coreRegistry->registry('current_category')
) {
$category = [];
$category['id'] = $_category->getId();
$category['name'] = $_category->getName();
$this->addVariable('category', $category);
$this->addVariable('list', 'category');
$category = [
'id' => $_category->getId(),
'name' => $_category->getName(),
];

$this->addVariable('category', $category);
$this->addVariable('list', 'category');
}

return $this;
Expand All @@ -141,11 +144,12 @@ protected function setProductDataLayer() {
) {
$this->addVariable('list', 'detail');

$product = [];
$product['id'] = $_product->getId();
$product['sku'] = $_product->getSku();
$product['name'] = $_product->getName();
// $this->addVariable('productPrice', $_product->getPrice());
$product = [
'id' => $_product->getId(),
'sku' => $_product->getSku(),
'name' => $_product->getName(),
];

$this->addVariable('product', $product);
}

Expand All @@ -161,7 +165,6 @@ protected function setCustomerDataLayer() {
$customer['isLoggedIn'] = true;
$customer['id'] = $this->_customerSession->getCustomerId();
$customer['groupId'] = $this->_customerSession->getCustomerGroupId();
//$customer['groupCode'] = ;
} else {
$customer['isLoggedIn'] = false;
}
Expand Down Expand Up @@ -193,7 +196,7 @@ protected function setCartDataLayer() {
'sku' => $item->getSku(),
'name' => $item->getName(),
'price' => $item->getPrice(),
'quantity' => $item->getQty()
'quantity' => $item->getQty(),
];
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"magento/framework": "100.0.*|100.1.*"
},
"type": "magento2-module",
"version": "1.2.1",
"version": "1.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MagePal_GoogleTagManager" setup_version="1.2.1">
<module name="MagePal_GoogleTagManager" setup_version="1.2.2">
<sequence>
<module name="Magento_Store"/>
</sequence>
Expand Down

0 comments on commit 53c94f0

Please sign in to comment.