Last active
December 23, 2021 10:24
-
-
Save keithgreer/a19e4b770766a17d7e8758d20bd3db8f to your computer and use it in GitHub Desktop.
M1: Import Values to Dropdown/Multiple Select Attributes - https://keithgreer.dev/import-values-to-dropdownmultiple-select-attributes
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'; | |
umask(); Mage::app('default'); | |
$_manufacturers = file('import.txt'); | |
$_attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product','manufacturer'); | |
$manufacturers = array('value'=> array(),'order'=> array(),'delete'=> array()); | |
$i = 0; | |
foreach($_manufacturers as $_manufacturer){ | |
$i++; | |
$manufacturers['value']['option_'. $i] = array($_manufacturer); | |
} | |
$_attribute->setOption($manufacturers); | |
try{ | |
$_attribute->save(); | |
echo 'Attribute values successfully imported'; | |
} catch(Exception $e){ | |
echo 'Import Error::'.$e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment