Last active
April 10, 2016 07:24
-
-
Save ryantbrown/6d7cd6a6c2283efc911e to your computer and use it in GitHub Desktop.
Magento - Add attribute option
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 | |
function addAttributeOption($attribute_code, $attribute_value) { | |
$attribute_model = Mage::getModel('eav/entity_attribute'); | |
$attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ; | |
$attribute_code = $attribute_model->getIdByCode('catalog_product', $attribute_code); | |
$attribute = $attribute_model->load($attribute_code); | |
$attribute_table = $attribute_options_model->setAttribute($attribute); | |
$options = $attribute_options_model->getAllOptions(false); | |
$value['option'] = array($attribute_value,$attribute_value); | |
$result = array('value' => $value); | |
$attribute->setData('option',$result); | |
$attribute->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment