Hi,
I had to fix a Fatal PHP Error in the Loader.php file to the path:
vendor/magento/module-configurable-product/Helper/Product/Options
I add this to line 52:
if (get_class($typeInstance) == 'Magento\Catalog\Model\Product\Type\Simple' || get_class($typeInstance) == 'Magento\Bundle\Model\Product\Type') { return null; }
This is my question:
Is it possible to create a custom moldule to overwrite this file?
I don’t want to edit the file Loader.php under the vendor path.
many thanks
<preference for="Magento\ConfigurableProduct\Helper\Product\Options\Loader" type="[Vendor]\[Extension]\Rewrite\Helper\Product\Options\Loader"/>
Thank you for your help. I try to explain what I did:
I created a custom module in app/code/Develoweb/ShippingError
A registration.php file to /app/code/Develoweb/ShippingError/:
<?php use \Magento\Framework\Component\ComponentRegistrar; ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Develoweb_ShippingError', __DIR__);
A module.xml file to /app/code/Develoweb/ShippingError/etc/:
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Develoweb_ShippingError" setup_version="1.0.0"> <sequence> <module name="ShippingError"/> </sequence> </module> </config>
A di.xml file to /app/code/Develoweb/ShippingError/etc/:
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\ConfigurableProduct\Helper\Product\Options\Loader" type="Develoweb\ShippingError\Rewrite\Helper\Product\Options\Loader"/> </config>
A Loader.php file (to overwrite the original file in the vendor folder) to
/app/code/Develoweb/ShippingError/Helper/Product/Options:
(this is the part of the code I replaced by line 50 of the original file)
/** @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);
unfortunately it doesn’t work and now I get another error
Initially I’m trying to solve this problem:
adding this code to the Loader.php file, the problem is solved:
if (get_class($typeInstance) == 'Magento\Catalog\Model\Product\Type\Simple' || get_class($typeInstance) == 'Magento\Bundle\Model\Product\Type') { return null; }
but I don’t want to do this in the Loader.php file under the vendor directory...
many thanks
How to negotiate for salary we should wait for the employer to make an offer before they start negotiating. This can lead to a significantly lower starting salary since it leaves room for negotiation.