12/17/2009

Adding images to magento using code (Programmaticaly)

Ive been working on automatically adding products to Magento from a 3rd party XML feed. 

The code to add an image to a product in Magento is:

$product->addImageToMediaGallery($imagePath, array('image','small_image','thumbnail'), false, true, $productData['data_display_name'] . " " . $productData['data_artist_display_name'] . " " . $productData['data_catalog_number']);

It is the array(’image’,’small_image’,'thumbnail’) which tells Magento that you are wanting to use this image as the small image, thumbnail and base image.

Source : http://allanbrown.me/

No comments:

Post a Comment