Skip to content

Instantly share code, notes, and snippets.

@bizlift
Last active June 12, 2019 05:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bizlift/15fce695d27ce9150f4705915522202a to your computer and use it in GitHub Desktop.
Save bizlift/15fce695d27ce9150f4705915522202a to your computer and use it in GitHub Desktop.
Magento configurable product default options by attribute label
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);
});
@bizlift
Copy link
Author

bizlift commented Sep 12, 2016

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(); ?>);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment