cancel
Showing results for 
Search instead for 
Did you mean: 

Create new manufacturer in magento 1.9.1.0

Create new manufacturer in magento 1.9.1.0

Hello I want to insert new manufacturer which is an attribute.

I use this code but it doesn't work:

 

$manu = 'MyManu';
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', 'manufacturer');
//for each store insert the manufacturer name
$attribute->setData( 'option', array( $manu, $manu, $manu,$manu, $manu, $manu, 0) ); $attribute->save(); //find the manufacturer created $manufacturerid = null; $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection') ->setAttributeFilter($attribute->getData('attribute_id')) ->setStoreFilter(0, false); foreach($valuesCollection as $value) { if ( $value->getValue() == $manu ) { $manufacturerid = $value->getOptionId(); break; } } echo $manufactureid.'<br />';