Skip to content

Commit 4d9179e

Browse files
committed
Improved ecomm_pagetype
1 parent 63392e4 commit 4d9179e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Model/AbstractDataLayer.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,36 @@ public function __construct(
106106
*/
107107
public function getEcommPageType(): string
108108
{
109+
if ('other' === $this->ecommPageType) {
110+
$fullActionName = $this->request->getFullActionName();
111+
switch ($fullActionName) {
112+
case 'cms_index_index':
113+
$this->ecommPageType = 'home';
114+
break;
115+
case 'catalog_category_view':
116+
$this->ecommPageType = 'category';
117+
break;
118+
case 'catalog_product_view':
119+
$this->ecommPageType = 'product';
120+
break;
121+
case 'checkout_cart_index':
122+
$this->ecommPageType = 'cart';
123+
break;
124+
case 'checkout_index_index':
125+
$this->ecommPageType = 'checkout';
126+
break;
127+
case 'contact_index_index':
128+
$this->ecommPageType = 'contact';
129+
break;
130+
case 'catalogsearch_result_index':
131+
$this->ecommPageType = 'searchresults';
132+
break;
133+
case 'cms_page_view':
134+
$this->ecommPageType = 'cmspage';
135+
break;
136+
}
137+
}
138+
109139
return $this->ecommPageType;
110140
}
111141

Model/DataLayer/BeginCheckout.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
class BeginCheckout extends AbstractDataLayer implements BeginCheckoutInterface
2020
{
21+
/**
22+
* @var string
23+
*/
24+
protected $ecommPageType = 'checkout';
25+
2126
/**
2227
* @var ItemInterface
2328
*/

Model/DataLayer/ViewItem.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
class ViewItem extends AbstractDataLayer implements ViewItemInterface
2020
{
21+
/**
22+
* @var string
23+
*/
24+
protected $ecommPageType = 'product';
25+
2126
/**
2227
* @var ItemInterface
2328
*/

0 commit comments

Comments
 (0)