Monday, 2 December 2019

Magento 2 Add Attribute Name To Configurable Select Option 'Choose a option..'

Configurable products display 'Choose an option...'. with Attribute option label like 'Color Choose an option...'


You also need to change that text in below file,

vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js
In this file, you need to find _fillSelect method and see "chooseText" value.

element.options[0].innerHTML = this.options.spConfig.chooseText

Replace with below code


var attribute_lable = this.options.spConfig.attributes[element.id.replace(/[a-z]*/, '')]['label']; element.options[0].innerHTML = attribute_lable +' ' + this.options.spConfig.chooseText; 

Thanks,