Skip to content

Instantly share code, notes, and snippets.

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 ViniciusAugusto/40c5dbc0b9415d3e7b3d to your computer and use it in GitHub Desktop.
Save ViniciusAugusto/40c5dbc0b9415d3e7b3d to your computer and use it in GitHub Desktop.
<?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