Last active
June 12, 2019 05:30
-
-
Save bizlift/15fce695d27ce9150f4705915522202a to your computer and use it in GitHub Desktop.
Magento configurable product default options by attribute label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Product.Config.prototype.fillSelect = Product.Config.prototype.fillSelect.wrap(function(superMethod, element){ | |
var attributeId = element.id.replace(/[a-z]*/, ''); | |
var attribute = this.config.attributes[attributeId]; | |
this.config.chooseText = 'Select ' + this.config.attributes[attributeId].label; | |
return superMethod(element); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A quick way to change the default option from "Choose an option" to "Select Color" (or size, or whatever your attributes are labeled as).
No modifications to any core classes or JS libraries. Just wrap fillSelect method of Product.Config before defining spConfig and it works with multiple attribute pulldowns.
Modify template/catalog/product/view/type/options/configurable.phtml
Add the above code between script tags directly before:
var spConfig = new Product.Config(<?php echo $this->getJsonConfig(); ?>);