add view item list fo details controller
This commit is contained in:
parent
824c19151b
commit
85eb11aaff
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use OxidEsales\Eshop\Application\Component\Widget\ArticleDetails;
|
||||
use OxidEsales\Eshop\Application\Controller\ArticleDetailsController;
|
||||
use OxidEsales\Eshop\Application\Model\ArticleList;
|
||||
|
||||
/**
|
||||
@ -54,15 +56,16 @@ class d3_google_articlelister
|
||||
}
|
||||
|
||||
/**
|
||||
* @param details $oView
|
||||
*
|
||||
* @return array
|
||||
* @param ArticleDetailsController $oView
|
||||
* @return ArticleList
|
||||
*/
|
||||
public function getDetailsProdList($oView)
|
||||
{
|
||||
$aArticleList = array();
|
||||
$aArticleList[] = $oView->getProduct();
|
||||
return $this->_getProductList($aArticleList);
|
||||
$oArticle = $oView->getProduct();
|
||||
$oArticleList = oxNew(ArticleList::class);
|
||||
$oArticleList->offsetSet($oArticle->getId(), $oArticle);
|
||||
|
||||
return $oArticleList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,11 +73,17 @@ class d3_google_articlelister
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
/**
|
||||
* @param ArticleDetails $oView
|
||||
* @return ArticleList
|
||||
*/
|
||||
public function getOxwarticledetailsProdList($oView)
|
||||
{
|
||||
$aArticleList = array();
|
||||
$aArticleList[] = $oView->getProduct();
|
||||
return $this->_getProductList($aArticleList);
|
||||
$oArticle = $oView->getProduct();
|
||||
$oArticleList = oxNew(ArticleList::class);
|
||||
$oArticleList->offsetSet($oArticle->getId(), $oArticle);
|
||||
|
||||
return $oArticleList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,6 +131,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
$oParentView->addTplParam('blIsImpressionViewList', true);
|
||||
$oParentView->addTplParam('aD3GAProdInfos', $this->d3GAGetProdInfos());
|
||||
$oParentView->addTplParam('sImpressionListType', $this->d3GAGetImpressionListType());
|
||||
$oParentView->addTplParam('sImpressionViewType', $this->d3GAGetImpressionViewType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,12 +140,23 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
public function isImpressionViewList()
|
||||
{
|
||||
// ToDo: has to be completed
|
||||
$impressionViews = ['search', 'start', 'alist', 'vendorlist', 'manufacturerlist'];
|
||||
$impressionViews = ['search', 'start', 'alist', 'vendorlist', 'manufacturerlist', 'details', 'oxwarticledetails'];
|
||||
$oCurrentView = Registry::getConfig()->getActiveView();
|
||||
|
||||
return in_array($oCurrentView->getClassKey(), $impressionViews);
|
||||
}
|
||||
|
||||
public function d3GAGetImpressionViewType()
|
||||
{
|
||||
switch (Registry::getConfig()->getActiveView()->getClassKey()) {
|
||||
case 'details':
|
||||
case 'oxwarticledetails':
|
||||
return 'view_item';
|
||||
default:
|
||||
return 'view_item_list';
|
||||
}
|
||||
}
|
||||
|
||||
public function d3GAGetImpressionListType()
|
||||
{
|
||||
$oCurrentView = Registry::getConfig()->getActiveView();
|
||||
|
@ -35,7 +35,7 @@ gtag('event', 'purchase', {
|
||||
|
||||
[{if $blIsImpressionViewList}]
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'view_item_list', {
|
||||
gtag('event', '[{$sImpressionViewType}]', {
|
||||
"items": [
|
||||
[{foreach from=$aD3GAProdInfos name="itemlist" item="item"}]
|
||||
[{assign var="oPrice" value=$item->getPrice()}]
|
||||
@ -50,30 +50,13 @@ gtag('event', 'purchase', {
|
||||
"variant": "",
|
||||
"list_position": [{$smarty.foreach.itemlist.iteration}],
|
||||
"quantity": 1,
|
||||
"price": [{$oPrice->getPrice()}]
|
||||
"price": '[{$oPrice->getPrice()}]'
|
||||
},
|
||||
[{/foreach}]
|
||||
]
|
||||
});
|
||||
[{/if}]
|
||||
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'view_item', {
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": '2.0'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
[{* https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce *}]
|
||||
gtag('event', 'add_to_cart', {
|
||||
"items": [
|
||||
|
Loading…
Reference in New Issue
Block a user