In Hyvä (and Magento generally), the displayed SKU does not change automatically when a shopper selects different options for a configurable product. A small code change can fix this.
Override the file /vendor/hyva-themes/magento2-default-theme/Magento_ConfigurableProduct/templates/product/view/type/options/js/configurable-options.phtml in your Hyvä child theme as follows:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
changeOption(attributeId, value) { ... this.updateSku(this.productIndex, this.optionConfig.sku); ... }, updateSku(selected, skus) { let sku = skus.hasOwnProperty(selected); if (sku) { document.getElementsByClassName('product-detail-value')[0].innerHTML = skus[selected]; return skus[selected]; } }, ... |
After reloading the product page, the SKU should update dynamically as the selected options change.
Dynamically changing the SKU of a configurable product in Hyvä
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.