1

How can I get the SKU of a simple product on a configurable product, after options are selected?

I tried this solution but I get various errors and issues which make me think it is outdated. Magento 2 - How to get the simple product Sku from the option selected of a configurable product

1 Answer 1

0

In order to display the SKU of the selected product, you can create a Plugin (Interceptor) for Magento\ConfigurableProduct\Block\Product\View\Type\Configurable::getJsonConfig() where you need to add missing SKU for each simple product. Out of the box, when choosing options, images, price, etc will change, but not SKU.

The SKU obtained with getJsonConfig() can be updated in the frontend when selecting an option in vendor/magento/module-swatches/view/base/web/js/swatch-renderer.js or/and vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js depending on the type of attribute (Dropdown, Visual Swatch, Text Swatch).


I made free VCT Change SKU Dynamically module that solve this problem.

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.