I'm fairly new to Magento and am currently running Magento 2.2.1. I am looking for a way to have the configurable sku change to the corresponding simple product sku when the configurable products attributes have been selected.
1 Answer
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 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.