2

When I add configurations to a configurable product the options get the sku undefined+attribute and not the name or sku of the configurable product. See screenshot below

Magento version: 2.1.10

enter image description here

1 Answer 1

0

In my case, I have disabled the "SKU" field and this was the problem

If you look into the vendor/magento/module-configurable-product/view/adminhtml/web/js/variations/variations.js::getProductValue() there is a selector with :enabled prop.

I fixed this by writing mixin in my custom module

app/code/MyCompany/MyModule/view/adminhtml/requirejs-config.js:

var config = {
    config: {
        mixins: {
            'Magento_ConfigurableProduct/js/variations/variations': {
                'MyCompany_MyModule/js/variations/variations': true
            }
        }
    }
}

app/code/MyCompany/MyModule/view/adminhtml/web/js/variations/variations.js:

define(
    [
        'uiComponent',
        'jquery'
    ],
    function (Component, $) {
        'use strict';
        return function (Variations) {
            return Variations.extend(
                {
                    /**
                     * @param {String} name
                     * @return {String|Number|Array}
                     */
                    getProductValue: function (name) {
                        name = name.split('/').join('][');

                        return $('[name="product[' + name + ']"]:not(.ignore-validate)', this.productForm).val();
                    }
                }
            );
        }
    }
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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