cancel
Showing results for 
Search instead for 
Did you mean: 

Configurable products not changing sku

Configurable products not changing sku

I am using Magento 2 CE 2.1.3.

SKU not changing dynamically in configurable product view page.

How can I fix it?

3 REPLIES 3

Re: Configurable products not changing sku

Hello,

 

I tried this solution and it work finally !!

https://codecanyon.net/item/magento-2-dynamic-configurable-product/22813380?s_rank=5

Regards,

Re: Configurable products not changing sku

Hello @SultanRana ,

 

ts default behavior of the Magento. but We can achieve it by coding.

I hope that you have basic knowledge of Magento.

 

  • Write a Plugin for Magento\ConfigurableProduct\Block\Product\View\Type\Configurable::getJsonConfig() and add the SKUs to the result:
    $config['skus'] = [];
    foreach ($subject->getAllowProducts() as $simpleProduct) {$config['skus'][$simpleProduct->getId()] = $simpleProduct->getSku();
    }
  • Extend Product.Config from app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/configurable.js using RequireJS. A good place to add the code to change the displayed SKU is reloadPrice(). You will have access to the SKUs via this.config.skus

 


--
If my answer is useful, please Accept as Solution & give Kudos

Re: Configurable products not changing sku

The Js you edit is for adminhtml. But what if i want to change sku in front-end when a different variant is clicked? I tried changing the same file in the frontend file but no result sadly.