switch metadata entries; fix getPrice-bug

This commit is contained in:
MaxBUhe 2023-05-23 10:06:21 +02:00
parent af78809ae5
commit 002cc69d2a
3 changed files with 39 additions and 43 deletions

View File

@ -1,6 +1,7 @@
[{$smarty.block.parent}] [{$smarty.block.parent}]
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}] [{assign var="d3ProductObject" value=$oView->getProduct()}]
[{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}]
[{capture assign=d3_ga4_add_to_cart}] [{capture assign=d3_ga4_add_to_cart}]
[{block name="d3_ga4_add_to_basket"}] [{block name="d3_ga4_add_to_basket"}]

View File

@ -1,35 +1,36 @@
[{assign var="gtmProducts" value=$products}] [{$smarty.block.parent}]
[{assign var="d3PriceObject" value=$gtmProducts->getPrice()}] [{assign var="gtmProducts" value=$products}]
[{assign var="breadCrumb" value=''}] [{assign var="breadCrumb" value=''}]
[{if $gtmProducts|@count}] [{if $gtmProducts|@count}]
[{strip}] [{strip}]
<script> <script>
/* ga4 */ /* ga4 */
dataLayer.push({ecommerce: null}); dataLayer.push({ecommerce: null});
dataLayer.push({ dataLayer.push({
'event':'view_item_list', 'event':'view_item_list',
'event_name': 'view_item_list', 'event_name': 'view_item_list',
'ecommerce': { 'ecommerce': {
'item_list_id': '[{$oView->getCategoryId()}]', 'item_list_id': '[{$oView->getCategoryId()}]',
'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]', 'item_list_name': '[{foreach from=$oView->getBreadCrumb() item=sCrum}][{if $sCrum.title }][{$breadCrumb|cat:$sCrum.title|cat:" > "}][{/if}][{/foreach}]',
'items': [ 'items': [
[{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}] [{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}]
[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] [{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
[{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}]
{ [{if !$gtmCategory}][{assign var="gtmCategory" value=$gtmProduct->getCategory()}][{/if}]
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]', {
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]', 'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
'price': [{$d3PriceObject->getPrice()}], 'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', 'price': [{$d3PriceObject->getPrice()}],
'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]', 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
'quantity': 1 'item_category': '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]-[{/if}]',
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}] 'quantity': 1
[{/foreach}] }[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
] [{/foreach}]
} ]
}); }
</script> });
[{/strip}] </script>
[{/strip}]
[{/if}] [{/if}]

View File

@ -43,17 +43,11 @@ $aModule = [
'block' => 'theme_svg_icons', 'block' => 'theme_svg_icons',
'file' => '/Application/views/blocks/_gtm_nojs.tpl' 'file' => '/Application/views/blocks/_gtm_nojs.tpl'
], ],
// widget_product_list
[
'template' => 'widget/product/list.tpl',
'block' => 'widget_product_list',
'file' => '/Application/views/blocks/widget_product_list.tpl'
],
// details // details
[ [
'template' => 'page/details/inc/productmain.tpl', 'template' => 'page/details/inc/productmain.tpl',
'block' => 'details_productmain_title', 'block' => 'details_productmain_title',
'file' => '/Application/views/blocks/detail.tpl', 'file' => '/Application/views/blocks/view_item.tpl',
'position' => 150 'position' => 150
], ],
// checkout // checkout
@ -71,7 +65,7 @@ $aModule = [
// view_item_list // view_item_list
[ [
'template' => 'widget/product/list.tpl', 'template' => 'widget/product/list.tpl',
'block' => 'd3Ga4_view_item_list', 'block' => 'widget_product_list',
'file' => '/Application/views/ga4/view_item_list.tpl', 'file' => '/Application/views/ga4/view_item_list.tpl',
'position' => 150 'position' => 150
], ],