Skip to content

Commit 5b812eb

Browse files
authored
Merge pull request #16 from magefan/9365-add-ecomm_pagetype-to-data-layer-and-export-plus-розширені-конверсії
9365-add-ecomm_pagetype-to-data-layer-and-export-plus-розширені-конве…
2 parents eb5a31f + 601d360 commit 5b812eb

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

Model/AbstractDataLayer.php

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class AbstractDataLayer
6262
*/
6363
protected $customerGroupCode;
6464

65+
/**
66+
* @var string
67+
*/
68+
protected $ecommPageType = 'other';
69+
6570
/**
6671
* AbstractDataLayer constructor.
6772
*
@@ -70,13 +75,13 @@ class AbstractDataLayer
7075
* @param CategoryRepositoryInterface $categoryRepository
7176
*/
7277
public function __construct(
73-
Config $config,
74-
StoreManagerInterface $storeManager,
78+
Config $config,
79+
StoreManagerInterface $storeManager,
7580
CategoryRepositoryInterface $categoryRepository,
76-
RequestInterface $request = null,
77-
Registry $registry = null,
78-
Session $session = null,
79-
GroupRepository $groupRepository = null
81+
RequestInterface $request = null,
82+
Registry $registry = null,
83+
Session $session = null,
84+
GroupRepository $groupRepository = null
8085
) {
8186
$this->config = $config;
8287
$this->storeManager = $storeManager;
@@ -95,6 +100,24 @@ public function __construct(
95100
);
96101
}
97102

103+
104+
/**
105+
* @return string
106+
*/
107+
public function getEcommPageType(): string
108+
{
109+
return $this->ecommPageType;
110+
}
111+
112+
/**
113+
* @param string $ecommPageType
114+
* @return void
115+
*/
116+
public function setEcommPageType(string $ecommPageType): void
117+
{
118+
$this->ecommPageType = $ecommPageType;
119+
}
120+
98121
/**
99122
* Get category names
100123
*
@@ -224,7 +247,7 @@ protected function getProductAttributeValue(Product $product, ?string $attribute
224247
if (is_array($result)) {
225248
$result = implode(', ', $result);
226249
}
227-
250+
228251
if ($result) {
229252
return (string)$result;
230253
}
@@ -268,6 +291,7 @@ protected function eventWrap(array $data): array
268291

269292
$data = $this->addCustomerGroup($data);
270293
$data = $this->addMfUniqueEventId($data);
294+
$data = $this->addEcommPageType($data);
271295

272296
return $data;
273297
}
@@ -299,4 +323,13 @@ protected function addMfUniqueEventId(array $data): array
299323

300324
return $data;
301325
}
326+
327+
protected function addEcommPageType(array $data): array
328+
{
329+
if (!isset($data['ecomm_pagetype'])) {
330+
$data['ecomm_pagetype'] = $this->getEcommPageType();
331+
}
332+
333+
return $data;
334+
}
302335
}

Model/DataLayer/Purchase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class Purchase extends AbstractDataLayer implements PurchaseInterface
2323
*/
2424
private $gtmItem;
2525

26+
/**
27+
* @var string
28+
*/
29+
protected $ecommPageType = 'purchase';
30+
2631
/**
2732
* Purchase constructor.
2833
*

0 commit comments

Comments
 (0)