Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Magento configurable product default options by attribute label
Product.Config.prototype.fillSelect = Product.Config.prototype.fillSelect.wrap(function(superMethod, element){
var attributeId =[a-z]*/, '');
var attribute = this.config.attributes[attributeId];
this.config.chooseText = 'Select ' + this.config.attributes[attributeId].label;
return superMethod(element);

This comment has been minimized.

Copy link
Owner Author

@bizlift 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