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

magento.stackexchange https://magento.stackexchange.com/questions/204524

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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
scroll top