rss
twitter
    Find out what I'm doing, Follow Me :)

Thursday, December 17, 2009

Pin It

Widgets

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/

1 comment:

  1. Do not set image for thumbnail, image or for image as default/

    ReplyDelete