Import Manufacturers
This is an old revision of the document!
Import Manufacturers: <br /> Sometimes it’s really a overhead when dealing with large number of manufacturers. In such case what you can follow the following simple steps for the import of manufacturers: 1> Create a file in the root of magento dir: manufacturer_import.php<br /> 2> Write the following code there:<br />
- <?php
- require_once 'app/Mage.php';
- umask(0);
- Mage::app('default');
- $_manufacturers = file('manufacturers.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 'Manufacturer successfully imported';
- }catch(Exception $e){
- echo 'Import Error::'.$e->getMessage();
- }
<br /> 3> Note i have used manufacturers.txt in the root dir with the values of manufacturers in newline format. For example:<br /> Dell<br /> Toshiba<br /> Sony<br /> Fujitsu<br /> ... and so on<br /> You can also use array instead. But above techniques comes into handy when you have hundreds of manufacturers.<br /> 4> Simply run from browser:<br /> http://my-magento-store/import_manufacturer.php<br /> 5> You are done.<br /> Note: Don’t repeat 4 unless you delete those values from backend manually.<br />
Todo: Skip the import for existing values.<br />
Thanks
— MagePsycho 2011/03/16 05:04


