1

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 ?

  • 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. – Rakesh Jesadiya Aug 16 '16 at 7:01
  • @rakesh can you give some example code to solve this because i am new to magento – Krishnakumar C Aug 16 '16 at 7:05
  • @Rakesh how you add multiple products to cart at one step from product details page – Krishnakumar C Aug 16 '16 at 7:07
  • magento.stackexchange.com/questions/122247/… check this link. – Rakesh Jesadiya Aug 16 '16 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. – Krishnakumar C Aug 16 '16 at 8:00
-1

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

  • This is not working in Magento 2.3.1 – Ghulam Akbar Oct 23 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. – Ghulam Akbar Oct 23 at 15:26

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.