0

The configurable product based on variation product images are changing, but not SKU, is there any way to change SKU also?

1

You have to override function getAllSizeImages() from Magento\Swatches\Helper\Data.php file.

 protected function getAllSizeImages(Product $product, $imageFile)
    {
        return [
            'large' => $this->imageHelper->init($product, 'product_page_image_large')
                ->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
                ->setImageFile($imageFile)
                ->getUrl(),
            'medium' => $this->imageHelper->init($product, 'product_page_image_medium')
                ->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
                ->setImageFile($imageFile)
                ->getUrl(),
            'small' => $this->imageHelper->init($product, 'product_page_image_small')
                ->setImageFile($imageFile)
                ->getUrl(),
            'sku' => $product->getSku()
        ];
    }

After change variant of product you have got response with sku of variant and you can change sku based on response using js.

0

I think you are about to searching for this solution. you will get exact answer on this discussion. Magento 2 - Why do SKU not change dynamically in configurable product view page

0

You might want to use the following FOSS module:

https://github.com/andering/magento2-configurable-dynamic

0

This work for me because its allow which you want to enable https://codecanyon.net/item/magento-2-dynamic-configurable-product/22813380?s_rank=5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.