0

I have an error that occurs in production only. And even then it is about 3/10 times that it occurs. Refresh, seems alright, refresh again, seems broken etc. On the staging site + my docker box it seems to work fine.

So the problem: The configurable product page is not being build 3 out of 10 times. Only a part of the following theme template is visible: Magento_ConfigurableProduct/templates/product/view/type/options/configurable.phtml .

The error starts from the $block->getJsonConfig() function in the template. It eventually calls on the function: $this->getData('media_gallery_images')->count(). This resides in: vendor/magento/module-catalog/Model/Product.php

This results in the error: Call to a member function count() on array.

The function: $this->getData('media_gallery_images') should always return an object as far as I know. So when it is an array it seem logical that it errors. I just cant figure out why it returns an array. Before that piece of code it also does the hasData check (with the setData) if it the check is false.

If you have an idea of the source of this problem, please post. I will investigate it then because I am at a loss at the moment.

Data: Magento 2.3.5 PHP 7.1.33

1
  • Could you specify where the script was located? – Marco Jun 17 at 9:41
1

Turns out there was a script running on production that runs $this->setData on all products turning objects into arrays and thus crashing when it runs a pre-defined method $this->getData('media_gallery_images')->count().

2
  • I am having the same issue, could you explain the fix some more? – Stephen Dance Jun 18 at 13:07
  • I have only been able to zoom into the problem, I have not been able to fix this – JerGrun Jun 21 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.