I want to select the options in each dropdown in product details page if it has one option.
for example

dropdown : 1 (option)
dropdown : 2 (option)
dropdown : 1 (option)

Then on the selection of the first drop down, the second drop down will be active for selection and when we select an option from the second drop-down then if the third drop down has only one option then it has to be selected as default

1 Answer 1


i have written this code in this file --> Magento_ConfigurableProduct/js/configurable.js (pub/static path) under the function "_fillSelect:" and after the "if (options) " condition close.

if (options.length == 1) {
                   this.options.values[attributeId] = options[0].id;
        if (element.options.length == 2)
            element.options.selectedIndex = 1;

Your Answer

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

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