Search code examples
magentomagento-1.5magento-1.6

Magento API: How can I assign an image to multiple products without re-uploading


The sites I work on (Magento 1.5 and 1.6) currently use a script that manually places images and then associates them using MySQL queries. I'm tasked with trying to move to an API-centric method so as to streamline things and integrate with other processes, and to move away from direct database manipulation (in case fields change and such).
The way our products are structured, we have a configurable item, which then has simple items for each color/size combination it's available in. For each color, there's only one set of images needed, regardless of size.

Example: Product A is a configurable product, with six associated simple products representing its two colors, black and red, with small, medium, and large sizes on each. Let's say I upload a set of images for red in size medium. I want to then use those same images for red in size small and large, not re-upload. Same process for the black one.

As it stands, it looks like I'd have to upload the image for each simple product. Is there any way to do what I want, or will I have to have stick with the old method?


Solution

  • I've played a lot with Magento API. I can confirm that the "catalog_product_attribute_media.create" is the only function that associate an image to a product. Using this function you will have to "upload" the image for each product you need it.

    Best regards Gisueppe

    (Sorry for my english)