0

We have an issue on checkout. Customers are not able to redirect on the payment gateway in some cases. Help is welcome.

We are using the Magento version 2.3.3 and we are getting below error.

Error: Uncaught exception 'Error' with message 'Call to undefined method Magento\Catalog\Model\Product\Type\Simple::getConfigurableAttributeCollection()' in /home/ortlieb/public_html/vendor/magento/module-configurable-product/Helper/Product/Options/Loader.php:52

Error: Uncaught exception 'Error' with message 'Call to undefined method Magento\Catalog\Model\Product\Type\Simple::getConfigurableAttributeCollection()' in /home/ortlieb/public_html/vendor/magento/module-configurable-product/Helper/Product/Options/Loader.php:52 in Magento\ConfigurableProduct\Helper\Product\Options\Loader::load called at /home/ortlieb/public_html/vendor/magento/module-configurable-product/Model/Product/ReadHandler.php (48) in Magento\ConfigurableProduct\Model\Product\ReadHandler::execute called at /home/ortlieb/public_html/vendor/magento/framework/EntityManager/Operation/Read/ReadExtensions.php (48) in Magento\Framework\EntityManager\Operation\Read\ReadExtensions::execute called at /home/ortlieb/public_html/vendor/magento/framework/EntityManager/Operation/Read.php (112) in Magento\Framework\EntityManager\Operation\Read::execute called at /home/ortlieb/public_html/vendor/magento/framework/EntityManager/EntityManager.php (70) in Magento\Framework\EntityManager\EntityManager::load called at /home/ortlieb/public_html/vendor/magento/module-catalog/Model/ResourceModel/Product.php (648) in Magento\Catalog\Model\ResourceModel\Product::load called at /home/ortlieb/public_html/generated/code/Magento/Catalog/Model/ResourceModel/Product/Interceptor.php (258) in Magento\Catalog\Model\ResourceModel\Product\Interceptor::load called at /home/ortlieb/public_html/vendor/magento/framework/Model/AbstractModel.php (540) in Magento\Framework\Model\AbstractModel::load called at /home/ortlieb/public_html/vendor/magento/framework/Interception/Interceptor.php (58) in Magento\Catalog\Model\Product\Interceptor::___callParent called at /home/ortlieb/public_html/vendor/magento/framework/Interception/Interceptor.php (138) in Magento\Catalog\Model\Product\Interceptor::Magento\Framework\Interception{closure} called at /home/ortlieb/public_html/vendor/magento/framework/Interception/Interceptor.php (153) in Magento\Catalog\Model\Product\Interceptor::___callPlugins called at

2

I found temporary solution adding simple condition in

Magento\ConfigurableProduct\Helper\Product\Options\Loader::load(ProductInterface $product) after line no : 51

if (get_class($typeInstance) == 'Magento\Catalog\Model\Product\Type\Simple' || get_class($typeInstance) == 'Magento\Bundle\Model\Product\Type')
{
            return null;
}
  • Thanks, this is working – Emile Nov 26 '19 at 10:48
1

You are using object Manager in anywhere and load product. I had the same issue and i resolved by

$objectManager->get('\Magento\Catalog\Model\Product')->load($productId);

into

$objectManager->create('\Magento\Catalog\Model\Product')->load($productId);

Hope it will work.

  • Hi, thank you. I'm no developer. Just store owner, could not find this code in any of the .php files from error. Could you tell me in which file in the system to change this? – Emile Nov 24 '19 at 20:41
0

To be complete. With the suggestions this is the full change

In /public_html/vendor/magento/module-configurable-product/Helper/Product/Options/Loade.php

Change

        $options = [];
    /** @var Configurable $typeInstance */
    $typeInstance = $product->getTypeInstance();
    $attributeCollection = $typeInstance->getConfigurableAttributeCollection($product);
    $this->extensionAttributesJoinProcessor->process($attributeCollection);
    foreach ($attributeCollection as $attribute) {

To

        $options = [];
    /** @var Configurable $typeInstance */
    $typeInstance = $product->getTypeInstance();
    if (get_class($typeInstance) == 'Magento\Catalog\Model\Product\Type\Simple' || get_class($typeInstance) == 'Magento\Bundle\Model\Product\Type')

{ return null; } $attributeCollection = $typeInstance->getConfigurableAttributeCollection($product); $this->extensionAttributesJoinProcessor->process($attributeCollection); foreach ($attributeCollection as $attribute) {

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.