2

I'm extending the \Magento\Catalog\Block\Product\View file in AddToCart.php.

In my AddTocart, I've added this line :

$stock = $this->isInStockCustom($sku);

Now, I'm adding options to my products. It was working find until now.

But if I add an option to this product, in my log, I have this

Invalid method Magento\Catalog\Block\Product\View\Interceptor::isInStockCustom [] []

But if I remove the options, I don't have this error anymore.

Any help would be very appreciated.

1 Answer 1

0

Go it :

also need to change this in catalog_product_view.xml:

<block class="Vendor\Module\Block\AddToCart" 
name="product.info.addtocart.additional" as="product.info.addtocart" 
template="Magento_Catalog::product/view/addtocart.phtml"/>

Because additional option and simple product are not the same.

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.