Created
September 25, 2015 11:13
-
-
Save ViniciusAugusto/40c5dbc0b9415d3e7b3d to your computer and use it in GitHub Desktop.
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 | |
require_once('app/Mage.php'); //Path to Magento | |
error_reporting(E_ALL); | |
ini_set("display_errors", 1); | |
umask(0); | |
Mage::app(); | |
$cores = array('AZUL CLARO', | |
'AZUL MARINHO', | |
'BEGE', | |
'BRANCO', | |
'CARAMELO', | |
'JEANS', | |
'LILÁS', | |
'MARROM', | |
'PRETO', | |
'ROSA', | |
'ROSA PINK', | |
'VERMELHO', | |
'VERMELHO ESCURO', | |
'VINHO' | |
); | |
addColor($cores); | |
function addColor($cores){ | |
$arg_attribute = 'color'; | |
$attr_model = Mage::getModel('catalog/resource_eav_attribute'); | |
$attr = $attr_model->loadByCode('catalog_product', $arg_attribute); | |
$attr_id = $attr->getAttributeId(); | |
foreach ($cores as $cor) { | |
echo $cor."<br />"; | |
$arg_value = $cor; | |
$option['attribute_id'] = $attr_id; | |
$option['value']['any_option_name'][0] = $arg_value; | |
$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); | |
$setup->addAttributeOption($option); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment