add image to mangento

$product->addImageToMediaGallery('ABSOLUTE_PATH','image',true,false);

select all

This snippet will add an image residing in ABSOLUTE_PATH to product, assign it to “image” attribute, move it from original location (true),

and uncheck the “Exclude” option (false). Here’s Magento documentation on the method:

void addImageToMediaGallery (string $file, [string|array $mediaAttribute = null], [boolean $move = false], [boolean $exclude = true])

Leave a Comment