I am looking to have the configurable SKU change to the corresponding simple product SKU when the configurable product attributes have been selected. Any help or suggestions would be appreciated.
-
Do you using only one configurable attribute or multiple mean size or size and color? – Amit Bera Oct 04 '18 at 05:46
-
I am using muliple – Ashna Oct 04 '18 at 06:00
1 Answers
Out of the box, when choosing options, the images and the price will change, but not SKU.
More information about which elements on the page change when options are selected can be found here: Magento\ConfigurableProduct\Block\Product\View\Type\Configurable::getJsonConfig().
In order to display product 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.
Switching SKU added in getJsonConfig() when selecting an option can be implemented in vendor/magento/module-swatches/view/base/web/js/swatch-renderer.js and vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js depending on the type of attribute.
I made free VCT Change SKU Dynamically module that solve this problem.
- 295
- 3
- 14
