Sometimes you need to override the class Magento\ConfigurableProduct\Helper\Product\Options\Loader.php .

This may be necessary, for example, to fix the Call to undefined method Magento\Catalog\Model\Product\Type\Simple\Interceptor::getConfigurableAttributeCollection() issue. A custom Magento 2 extension is often the best place for this override.

Follow these steps:

Add the following content to the di.xml file in your extension:

Create the class Loader.php at the following path: Vendor/Module/ConfigurableProduct/Helper/Product/Options/Loader.php

That’s it.

In this example, the load Funktion was modified to fix the issue Call to undefined method Magento\Catalog\Model\Product\Type\Simple\Interceptor::getConfigurableAttributeCollection() . The following code was added to Loader.php:

Overriding Loader.php to fix undefined getConfigurableAttributeCollection() method
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.
Tags: