danslo / ApiImport

Boilerplate between the Magento API and ImportExport, so that you can do fast Array/XMLRPC/SOAP based product imports.
244 stars 79 forks source link

Need some help to add image support in ApiImport #16

Closed willy-ahva closed 10 years ago

willy-ahva commented 10 years ago

Hello @danslo,

Can you take a look at my improvement on my github ? https://github.com/willy-ahva/ApiImport/compare/enhancement/imageSupport

I try to add in ApiImport the image support. According to the documentation (http://www.magentocommerce.com/knowledge-base/entry/importing-product-images), the array i send to the api is : http://pastebin.com/uC7FXeeV but I also try : http://pastebin.com/FX3qK210 and some others ...

Actually, images are well imported in magento in media/import and then moved in media/catalog/product, but I've never been able to associate an image to the product. I tried a lot of things to debug but all seems to be good and I no longer have idea ...

Maybe, when it will be finished I'll can send you a pull request. I hope you can help me, Thank you !

danslo commented 10 years ago

If I remember correctly, you also need to set _media_image (to associate it to the product), this is a snippet from some older code I wrote:

/**
 * Prefix images so that ImportExport can pick them up.
 */
foreach ($images as &$image) {
    $image['_media_image'] = DS . $image['_media_image'];
}

/**
 * Now map the first one of these images to each of the image types.
 */
foreach (array('image', 'small_image', 'thumbnail') as $imageType) {
    $images[0][$imageType] = $images[0]['_media_image'];
}

Also you will need to set _media_attribute_id, which you can find using:

$mediaAttributeId = Mage::getModel('eav/entity_attribute')
    ->load('media_gallery', 'attribute_code')
    ->getAttributeId();
willy-ahva commented 10 years ago

Thanks a lot for your quick response ! I'll try it and when it works i'll send you a PR.

willy-ahva commented 10 years ago

Ok it works well ! I'll send you a PR when my code will be cleaned and when I have made a doc for it in some days/weeks.

Thank you for your help @danslo, ApiImport is a good project !

EDIT : Just for information, I did some benchmark with ApiImport and it seems that best performance is achieved sending bulk of 2500 rows. https://docs.google.com/spreadsheets/d/1h-u-QlvG7OguKGc9zskdx3839pUm56khMHXrKxKKj5Y/edit?usp=sharing

danslo commented 10 years ago

:+1: