Magento2: Fatal error with Google Tag Manager on Magento Cloud Commerce 2.2.5

Created on 10 Jan 2019  路  9Comments  路  Source: magento/magento2

Preconditions (*)

  1. Magento Cloud Commerce 2.2.5
  2. Google Tag Manager enabled

Steps to reproduce (*)

  1. Enabling Google Tag Manager
    2.

Expected result (*)

  1. Product page displayed
    2.

Actual result (*)

  1. Failure when display a product page
  2. Fatal error: Uncaught Error: Call to a member function getLoadedProductCollection() on boolean in /app/vendor/magento/module-google-tag-manager/Block/ListJson.php:206 Stack trace: #0 /app/vendor/magento/module-google-tag-manager/Block/ListJson.php(190): Magento\GoogleTagManager\Block\ListJson->_getProductCollection() #1 /app/vendor/magento/module-google-tag-manager/Block/ListJson.php(240): Magento\GoogleTagManager\Block\ListJson->_getProducts() #2 /app/vendor/magento/module-google-tag-manager/view/frontend/templates/impression.phtml(11): Magento\GoogleTagManager\Block\ListJson->getLoadedProductCollection() #3 /app/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/app/vendor/mag...') #4 /app/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\ViewTemplateEngine\Php->render(Object(Magento\GoogleTagManager\Block\ListJson), '/app/vendor/mag...', Array) #5 /app/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\ElementTemplate->fetchView('/app/vendor/mag.. in /app/vendor/magento/module-google-tag-manager/Block/ListJson.php on line 206Fatal error: Uncaught Error: Call to a member function getLoadedProductCollection() on boolean in /app/vendor/magento/module-google-tag-manager/Block/ListJson.php:206 Stack trace: #0 /app/vendor/magento/module-google-tag-manager/Block/ListJson.php(190): Magento\GoogleTagManager\Block\ListJson->_getProductCollection() #1 /app/vendor/magento/module-google-tag-manager/Block/ListJson.php(240): Magento\GoogleTagManager\Block\ListJson->_getProducts() #2 /app/vendor/magento/module-google-tag-manager/view/frontend/templates/impression.phtml(11): Magento\GoogleTagManager\Block\ListJson->getLoadedProductCollection() #3 /app/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/app/vendor/mag...') #4 /app/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\ViewTemplateEngine\Php->render(Object(Magento\GoogleTagManager\Block\ListJson), '/app/vendor/mag...', Array) #5 /app/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\ElementTemplate->fetchView('/app/vendor/mag.. in /app/vendor/magento/module-google-tag-manager/Block/ListJson.php on line #206
Clear Description Format is valid

All 9 comments

Hi @jfgalano. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@jfgalano do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @irajneeshgupta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [x] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [x] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 6. Add label Issue: Confirmed once verification is complete.

  • [ ] 7. Make sure that automatic system confirms that report has been added to the backlog.

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 6. Add label Issue: Confirmed once verification is complete.

  • [ ] 7. Make sure that automatic system confirms that report has been added to the backlog.

hi @jfgalano
GitHub is intended for Magento Open Source users to report on issues related to Open Source only.
You can report Commerce-related issues in one of two ways:
You can use the Support portal associated with your account
or
If you are a Partner reporting on behalf of a merchant, use the Partner portal.

@irajneeshgupta I recently had this problem, are you still able to look into this?

I am running Magento Enterprise 2.2.7.

The issue is that there are hardcoded block names in magento/module-google-tag-manager/view/frontend/layout/catalog_product_view.xml such as product.info.upsell. These block names are used in \Magento\GoogleTagManager\Block\ListJson::getListBlock to retrieve information, but in my case we had removed the product.info.upsell block in a theme layout file so the code broke at \Magento\GoogleTagManager\Block\ListJson::206 due to the getListBlock method returning false (because of the missing block) and there being no code that verifies whether the block actually exists or not.

HI @sjb9774 the google-tag-manager available only in EE version, We can accept only CE issues.

This happens if you removed catalog.product.related or product.info.upsell block.
Reference: vendor/magento/module-google-tag-manager/view/frontend/layout/catalog_product_view.xml
Tag manager expects these blocks to be present on a product page.
There has been fixed in EE repo.

Was there a permanent fix applied to this?
The link in @snowcore comment doesn't work anymore.

@jfgalano @Ohopwood
This happens if you removed any one of these catalog.product.related or product.info.upsell or checkout.cart.crosssell or search_result_list or checkout.cart.crosssell or category.products.list block(s).
To make it work i created a patch.

Hope this will help.

Was this page helpful?
0 / 5 - 0 ratings