Hi there, I need a simple batch/task to import product by a cron. I noticed the usefull method “importFromTextArray” from the “catalog/product” model.
Here is my snippet:
$row = array ( 'sku' => 'test-sku-123', 'store' => 0, 'attribute_set' => 'Default', 'type' => 'Simple Product', 'categories' => '12,25', 'name' => 'My Uber Product', 'description' => 'Here is the description of this product.', 'price' => 33.95, 'short_description' => 'Here is the description...', 'weight' => 0, 'status' => 'Enabled', 'tax_class_id' => 'Taxable Goods', 'qty' => 100, // do not work :( 'use_config_min_qty' => 1, // do not work :( 'use_config_backorders' => '1', // do not work :( 'use_config_min_sale_qty' => true, // do not work :( 'use_config_max_sale_qty' => 1, // do not work :( 'use_config_notify_stock_qty' => '1', // do not work :( // ... );
This code snippet works almost but not fully, some attributes do not work like “qty” for example. Am i doing wrong something or is it some kind of bug?
Is there a simple way to go over it? Any advices, code samples, ... would be nice
"qty” is not stored with the product and is stored in a different table cataloginventory_stock_item’. The importFroTextArray is useful for importing product attributes alone. For code to import the stock refer to “$stockItem->save();” in Mage_Catalog_Model_Convert_Adapter_Product.saveRow() method
Now I also can import the picture corresponding to this product… I thought I needed another object like for the stock item, but the tricky part is in fact that I need to do a fake uplad (in fact I just copy this picture in a temp folder...)
I hope this can help some people like me, if you find a better/cleanner way just leave your advices under this post… I also wish this could be part of a wiki article but I don’t have much time to post this…
but i have to open and save all the added products, i looked into the database and i think there are some attributes that have to be set aswell
like meta title, meta keyword, meta description, url path, custom design and custom layout update (at least that attribs are set when saving the product via the backend)
seems that there are more tables touched, like the core_url_rewrite and so on…
FOUND IT OUT in catalog_product_website must be an entry with product_id and website_id - then the newly added product is shown in the shop…
Ok this is great, I think that if you forget the “websiteid”, the default is selected… For me the last missing(not working ?) feature is that I cannot tell Magento about the maedi_gallery and the values (this picture is the thumbnail, the other one is the base picture… etc).
I used your script example to import my products.
It is working fine!
I am importing 3 pictures for each product. Thumbnail, small_image and image.
This is also working fine.
But how can I say, which picture I have imported is the thumbnail, which one is the small_image and which one is the image?
ooh ok. There is a new function for that in 1.0?
Can you giv me a hint?
or do you know how to do the import i descriped with the old function?
Everything is working. I only have to assign which picture is thumbnail, which one is small_image and so on.