2

I am getting

Warning: Illegal offset type in vendor/magento/module-catalog/Model/CategoryRepository.php on line 133

on product details page in Magento 2.1.8 Which is caused by

vendor/magento/module-catalog/Block/Product/ListProduct.php(114)

Please refer screenshot - code from ListProduct.php code from ListProduct.php file

Code from CategoryRepository.php enter image description here

2
  • did you try to refresh cache by cache:flush and cache:clean command?
    – Ashish Raj
    Dec 5 '17 at 12:24
  • Yes I had try cache:flush. Still getting same error
    – user41818
    Dec 5 '17 at 12:31
0

Had the same issue in 2.1.8. Though for me it only occured when the FPC was enabled. It seems to be caused by:

$this->setCategoryId(current($categories->getIterator()));

in vendor/magento/module-catalog/Block/Product/ListProduct.php. An issue that was fixed in Magento 2.2.0. New code is:

$this->setCategoryId(current($categories->getIterator())->getId());

Upgrading to 2.2.x should resolve the issue. If that's not an option you could also try disabling FPC.

2
  • If I disable FPC then what about performance?
    – user41818
    Dec 6 '17 at 13:14
  • It'll obviously have effect on your shop's performance. It's up to you to decide which way to go. Another option would be to temporarily disable all blocks that use ListProduct.php until you can upgrade (related products/upsell/etc). That's not something that I can judge for you.
    – sduif
    Dec 6 '17 at 13:27

Your Answer

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