0

I made an upgrade from v2.3.3 to v2.3.4 and now when I try to edit a product I receive this error:

Warning: Invalid argument supplied for foreach() in /vendor/magento/module-catalog/Model/ProductLink/CollectionProvider.php on line 185

Any idea where this error might be?

BR

2 Answers 2

0

in exception.log, I found this error

temando.CRITICAL: "accountId" is required. Enter and try again. {"exception":"[object] (Magento\\Framework\\Exception\\InputException(code: 0): \"accountId\" is required. Enter and try again. at /public_html/vendor/magento/framework/Exception/InputException.php:91)"}

after I search on google I found this solution https://magenaut.com/fix-error-after-disable-temando_shipping/

1
  • I deactivated the Temando Shipping module and deleted the files but the error persists in the admin. Commented Mar 3, 2020 at 15:33
0

The Temando extension disabled can't fix the same problem for me. I found this variable $this->mapProviders is empty in /vendor/magento/module-catalog/Model/ProductLink/CollectionProvider.php file. This caused the problem. not sure what happened. I solved this problem by modifying the core magento file in /vendor/magento/module-catalog/Model/ProductLink/CollectionProvider.php. In getMap function, add this after if (!$types) {...}. So it'd be:

...
public function getMap(array $products, array $types): array
{
    if (!$types) {
        throw new \InvalidArgumentException('Types are required');
    }
   //FIX Warning: Invalid argument supplied for foreach() in /vendor/magento/module-catalog/Model/ProductLink/CollectionProvider.php on line 185
    if (!(is_array($this->mapProviders))) {
        $this->mapProviders = array(
            ObjectManager::getInstance()->create(LinkedMapProvider::class)
        );
    }
   ...
}
...

You need to import a few files as well on the top of this file:

use Magento\Catalog\Model\ProductLink\CollectionProvider\LinkedMapProvider;
use Magento\Framework\App\ObjectManager;

I know this fix is not clean as magento way. let me know if there is a better fix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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