You can avoid writing to the database directly like this:$prod->setMediaGallery(array('images' => array(), 'values' => array()));$prod->addImageToMediaGallery($image_path, array('thumbnail'), false, false);the other input strings are 'image' for the base image, and 'small_image' for the small image. http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Model_Product.html#...
@Jordan wow I had no idea it was so simple, I tried using the media gallery methods but I had no luck, and I couldn't find anything in the Magento documentation, thanks a lot for the comment!In my method the input strings correspond with the attribute_ids of 74, 75, and 76 so I did it that way, as I couldn't find image and small_image keys in the convoluted database structure
You can avoid writing to the database directly like this:$prod->setMediaGallery(array('images' => array(), 'values' => array()));$prod->addImageToMediaGallery($image_path, array('thumbnail'), false, false);the other input strings are 'image' for the base image, and 'small_image' for the small image. http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Model_Product.html#...
ReplyDelete@Jordan wow I had no idea it was so simple, I tried using the media gallery methods but I had no luck, and I couldn't find anything in the Magento documentation, thanks a lot for the comment!In my method the input strings correspond with the attribute_ids of 74, 75, and 76 so I did it that way, as I couldn't find image and small_image keys in the convoluted database structure
ReplyDelete