-
- icvu

-
Total Posts: 10
Joined: 2009-01-25
|
Hi, All—I have been working on how to assigned a manufacturer on a dropdown attribute to a product during product import, but got no where for the past few days.
Basically, I am working on layered navigation, so I created an attribute called “manufacturers”, which is a dropdown type. I assigned all the manufacturers as the values during the creation of the attribute by a separate script.
I have about 2000 products that I need to import and assigned each product a manufacturer from all of the ones available in the “manufacturers” attribute. How do I assign a manufacturer to a product import using direct data import?
$productData is an array containing all the product attributes and their value. My problem is I don’t know how to programatically assign an attribute of type “select” for each product that I import.
For example, if the “manufacturers” attribute of type ‘select’ has the following values, how to I select the second one on the list to use during product import?
manufactuter contains “Sony”, “Samsung”, “JVC”, ...etc.
$productData[$attributeCode]=$attributeValue;
So, what I have don’t and know how is $productData[’manufacturers’] = ‘Samsung’. And this does not work, because when the product is imported the value for the attribute “manufacturer” is “no” not “Samsung”.
$product = Mage::getModel('catalog/product'); $product->setWebsiteIds(array(1)); $product->setStoreId(1); $product->setStore(1); $product->setAttributeSetId(isset($productData['attributeSetId']) ? $productData['attributeSetId'] : 9); $product->setSku($productData['sku']); $product->setTypeId('simple'); $product->setName($productData['name']); $product->setDescription('this is the description'); $product->setShortDescription('This is the short description'); $product->setPrice($productData['price']); //if(isset($productData['special_price'])) $product->setSpecialPrice($productData['special_price']); $product->setWeight($productData['weight']); $product->setStatus(1); // enabled $product->setTaxClassId(2); // taxable goods $product->setCategoryIds($productData['category_ids']); $product->setVisibility( isset($productData['visibility']) ? $productData['visibility'] : 4 ); $product->addData($productData); $product->save();
I also tried using the product import API. But I do not know how to assign an attribute of type select or dropdown a value. I know how to assign attributes of type ‘text’.
$proxy->call($sessionId, 'product.create', array('simple',//product type $sets[$category],//attribute set id from the Magento, the attribute set has to exist in Magento otherwise this will break. "$sku",//the sku of the product, the sku has the be inserted as a string $productData //the product data ));
At this point it’s getting frustrating because I spent about 3 days on it already. Any help is much appreciated.
|