title: Magento Programming: Importing manufacturers while checking for existing duplicates and get manu. ID
body: <p>I need some help doing the following.</p>
  
  <p>I am trying to import a list of manufacturers with pre-verification from the targeted store that new manufacturer to be imported does not already exist (if new manufacturer name already exist, skip) and get its new manufacturer ID if imported.</p>
  
  <p>I have the code to just add manufacturer w/o checking for existing manufacturer by name nor getting the new manufacturer ID.  The code is here, but I need the abilities thats stated above.</p>
  
  <p>Any help would be great. Thanks in advance.</p>
  
  <pre><code>&lt;?php
  require_once 'app/Mage.php';
  umask(0);
  Mage::app('default');
  $_manufacturers = file('manufacturers.txt');
  $_attribute = Mage::getModel('eav/entity_attribute')-&gt;loadByCode('catalog_product', 'manufacturer');
  $manufacturers = array('value' =&gt; array(), 'order' =&gt; array(), 'delete' =&gt; array());
  $i = 0;
  foreach($_manufacturers as $_manufacturer){
  $i++;
  $manufacturers['value']['option_' . $i] = array($_manufacturer);
  }
  $_attribute-&gt;setOption($manufacturers);
  try{
  $_attribute-&gt;save();
  echo 'Manufacturer successfully imported';
  }catch(Exception $e){
  echo 'Import Error::'.$e-&gt;getMessage();
  }
  
  ?&gt; 
  </code></pre>