Last active
August 29, 2015 14:05
-
-
Save rickbenetti/66b6f51545a285013c60 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/22005824/disable-choose-an-option-in-configurable-products-of-magento Como remover o label de dentro do dropdown de opções.
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
<?php | |
$_product = $this->getProduct(); | |
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes()); | |
?> | |
<?php if ($_product->isSaleable() && count($_attributes)):?> | |
<?php //Irá exibir o valor do atributo no label como: Cor, Tamanho, Dimensões e etc... ?> | |
<div class="options"> | |
<label for="super_attribute[<?php echo $_attribute->getAttributeId() ?>]"><?php echo $_attribute->getProductAttribute()->getAttributeCode(); ?></label> | |
<div class="dropdown-select"> | |
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select"> | |
</select> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>); | |
//we create new function | |
spConfig.setInitialState = function(dropdown_id) { | |
//select dropdown | |
var dropdown = $(dropdown_id); | |
//remove empty option from dropdown so it is not selectable after initial selection. | |
dropdown[0].remove(); | |
//change selections in dropdowns | |
for(index = 0; index < dropdown.length; index++) { | |
if(dropdown[index].value != "") { | |
dropdown.selectedIndex = index; | |
var element = dropdown; | |
var event = 'change'; | |
//fire events | |
if(document.createEventObject) { | |
var evt = document.createEventObject(); | |
return element.fireEvent('on'+event,evt) | |
} | |
else { | |
var evt = document.createEvent("HTMLEvents"); | |
evt.initEvent(event, true, true ); | |
return !element.dispatchEvent(evt); | |
} | |
} | |
} | |
}; | |
<?php foreach($_attributes as $_attribute): ?> | |
spConfig.setInitialState("attribute<?php echo $_attribute->getAttributeId() ?>") | |
<?php endforeach; ?> | |
</script> | |
<?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment