How to solve compatibility issues - Google Tag Manager Enhanced Ecommerce

Follow

Comments

4 comments

  • Avatar
    Andrei Leev

    First of all i would like to thank WeltPixel team for taking time and documenting this issue.
    Unluckily I am within those whose theme "product category grid screws up" 

    By the way, i use "Porto Magento Theme"

    In my case product grid when Google Tag Manager is enabled product grid went from 4 rows ended up with 2 rows ( & reconfiguring theme settings didn't help)

    So i found this tutorial & managed to comment out code in app/code/WeltPixel/GoogleTagManager/view/frontend/layout/default.xml

    By commenting out the code in default.xml (this solved issue with grid)
    I'm not a developer but as I understand by commenting out part of a code from module I limited some of its features?

    Would appreciate a lot if you could leave a comment on that... 

    Also i found app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/list.phtml

    In my case, it was different from what I saw here, again not a developer but changed it..

    From

    <?php // Product Image ?>
    <div class="product photo product-item-photo">
    <a href="<?php echo $_product->getProductUrl() ?>" tabindex="-1">
    <?php
    if($_category_config['aspect_ratio'])
    $productImage = $_imagehelper->init($_product, $image)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($image_width);
    else
    $productImage = $_imagehelper->init($_product, $image)->resize($image_width, $image_height);
    $productImageUrl = $productImage->getUrl();
    ?>
    <img class="product-image-photo default_image" src="<?php echo $productImageUrl; ?>" alt="<?php echo $productImage->getLabel(); ?>"/>
    <?php if($_category_config['alternative_image']): ?>
    <?php
    if($_category_config['aspect_ratio'])
    $productHoverImage = $_imagehelper->init($_product, $hover_image)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($image_width);
    else
    $productHoverImage = $_imagehelper->init($_product, $hover_image)->resize($image_width, $image_height);
    $productHoverImageUrl = $productHoverImage->getUrl();
    ?>
    <?php if($productImageUrl != str_replace("/thumbnail/","/small_image/",$productHoverImageUrl)): ?>
    <img class="product-image-photo hover_image" src="<?php echo $productHoverImageUrl; ?>" alt="<?php echo $productHoverImage->getLabel(); ?>"/>
    <?php endif; ?>
    <?php endif; ?>
    </a>

    TO

    <?php // Product Image ?>
    <div class="product photo product-item-photo">
    <a href="<?php echo $_product->getProductUrl() ?>" tabindex="-1">
    <a <?php echo $this->helper('WeltPixel\GoogleTagManager\Helper\Data')>getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
    <?php echo $productImage->toHtml(); ?>
    </a>

    Now everything seems to be working fine, but again im not sure if i could messed up some of the modules features whitch i dont see yet. So would appreciate WeltPixels comment alot! 

  • Avatar
    MrPaulsky

    @Andrei Leev Thank you, we had the same problem with Porto theme. So you comment out the part in app/code/WeltPixel/GoogleTageManager/view/frontend/layout/default.xml 

    And edit the file app/design/frontend/Smartwave/THEME/Magento_Catalog/template/product/list.phtml this way (I'm using a child theme, so I copied the file from the porto parent theme.):

    (Around line 70 Porto 3.0.6):

    Edit 

    <a <?php href="<?php echo $_product->getProductUrl() ?>" tabindex="-1">

    To

    <a <?php echo $this->helper('WeltPixel\GoogleTagManager\Helper\Data')->addProductClick($_product, $iterator-1); ?> href="<?php echo $_product->getProductUrl() ?>" tabindex="-1">
  • Avatar
    Adam Balint

    Is this real, that the official documentation recommends to change the core code of the module? This is not a real solution, only an ugly hack. A composer update, or any plugin update will overwrite the modification...

    Why don't you add a switch under config, which can turn on/off these overrides?

  • Avatar
    Support Tier 2

    Adam,

    Good point. Already added an option for it starting with version 1.7.3 - August 23, 2018. 

Please sign in to leave a comment.