0

I have a problem and it is that if in my bundle product, one of my simple products that composes it is not found, it continues to appear as a product and it shouldn't, I want it to show the out of stock message if it doesn't meet the condition. enter image description here

2
  • By default, Magento won't allow you to add to the cart if one of the child products is out of stock. Looks to me it's your theme issue? Commented May 19, 2022 at 23:32
  • yes, but it does allow adding and the idea is that it does not allow and in that case I want to show a span just like in the simple products out of stock Commented May 20, 2022 at 0:11

1 Answer 1

0

You need to override listing block and write you logic, you can check for all simple product associated with bundle product and then check for the stock availability. and accordingly you can show/hide the add to cart button or just set product status to out of stock. if you need code please ask, I will provide you the snippet.

6
  • i writte a block in app/design/frontend/Myvendor/mytheme/Magento_Catalog/Block/Product/ListProduct.php and app/design/frontend/Myvendor/mytheme/Magento_Catalog/Block/Product/View/AbstractView.php to show in PLP app/design/frontend/Myvendor/mytheme/Magento_Catalog/templates/product/list.phtml but it doesn't show anything, I'm doing something wrong Commented May 20, 2022 at 16:22
  • have you added preference for your block? if not then please create ect/di.xml file and add preference to your block
    – Rohit
    Commented May 23, 2022 at 7:28
  • i add the app/design/frontend/Vendor/theme/Magento_Catalog/Block/Product/ListProduct.php file, but ow show or get in my templates? Commented May 25, 2022 at 13:08
  • Have you created preference in di.xml file
    – Rohit
    Commented May 25, 2022 at 13:41
  • how preference? i dont know Commented May 25, 2022 at 13:41

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.