2

I am just extended configurable block using a custom block, but I couldn't get the "selected_configurable_option" while changing the configurable options [ not getting simple product id ].

enter image description here

Did this can be achieved by extending the block like Block Test.php

class Test extends \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable{
}

di.xml

<?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\Checkout\Controller\Cart\Add" type="Vendor\MultipleProductsToCart\Controller\Cart\Add" />
    <preference for="Magento\ConfigurableProduct\Block\Product\View\Type\Configurable" type="Vendor\MultipleProductsToCart\Block\Catalog\Product\Test" />
 </config>

or do I need to override the configurable.phtml. How to solve this problem ?

5
  • you have to do using Plugin method, you can't override configurable block, but why configurable.php block is not override that' not found yet for me. Aug 16, 2016 at 7:01
  • @rakesh can you give some example code to solve this because i am new to magento Aug 16, 2016 at 7:05
  • @Rakesh how you add multiple products to cart at one step from product details page Aug 16, 2016 at 7:07
  • magento.stackexchange.com/questions/122247/… check this link. Aug 16, 2016 at 7:08
  • @Rakesh: How will we customize configurable block without overriding configurable.phtml, I need to change the view of configurable block to add multiple products to cart also need to add quantity filed for each simple product. Aug 16, 2016 at 8:00

1 Answer 1

0

Using a custom Theme:

  1. Create folder app/design/frontend/<Vendor>/<Theme>/Magento_ConfigurableProduct/templates/product/view/type/options/
  2. Copy the file from vendor/magento/module-configurable-product/view/frontend/templates/product/view/type/options/configurable.phtml there
  3. Edit as you wish (e.g. add a console.log)
  4. Flush Cache Storage

I reckon that is a bit late, but works on Magento 2.1.7

3
  • This is not working in Magento 2.3.1 Oct 23, 2019 at 15:22
  • This is not working in magento 2.3.1. I am using similar approch to over-write Grouped product info inside app/design/frontend/<Vendor>/<Theme>/Magento_GroupedProduct/templates/product/view/type/grouped.phtml. And Grouped product is working but why configurable product is not working using respective file & folder info. Oct 23, 2019 at 15:26
  • Worked fine for me in 2.3.5 Feb 5, 2021 at 1:42

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.