Connect to the Magento database

This function create the Mage object.

require_once '../app/Mage.php';
ini_set('display_errors', 1);
Mage::app('admin');
Mage::setIsDeveloperMode(true);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$attributeCode = 'color';
// read new option values from CSV
$newOptionValues = readOptions();
// read existing options
$optionsExists = readExistingAttribute( $attributeCode );
//compare with existing options;
$newOptions = cmpOptions( $newOptionValues, $optionsExists );
createAttribute( $newOptions, $attributeCode);

Share this Tutorial