Add attribute name to configurable select option in Magento2?

Open the file


and find this line

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

repleace the line with below code

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

On page load change dropdown label,
Open the file


and find the line

<option value=""><?= /* @escapeNotVerified */ __('Choose an Option...') ?></option>

repleace the line with below code

$attrlabel = array();(Declared before loop)
$attrlabel[$i] = $_attribute->getProductAttribute()->getStoreLabel();?>
<option value=""><?phpecho 'Choose '.$attrlabel[$i];?></option>

Leave a Reply

Your email address will not be published. Required fields are marked *