Adding images to product gallery — Can't get media type to stick

AF

New Member
I'm trying to add base, small, and thumbnail images to all of my products programmatically. The images are importing fine and being placed into \[code\]/media/catalog/product\[/code\] as expected, but only 'Base Image' is selected when I view the product's images in the Magento backend.I'm looping through each product in the catalog and running:\[code\]$mediaArray = array('thumbnail', 'small_image', 'image'); $file = Mage::getBaseDir('media') . DS . 'import' . trim($imageName);try { $product->addImageToMediaGallery($file, $mediaArray, false, false); $product->save();} catch (Exception $e) { echo $e->getMessage();}\[/code\]All of my image names start with a slash, and the images themselves are uploaded to \[code\]/media/import\[/code\]. I'm attempting to mimic what the Mage product importer would do.Any insight on why the small and thumbnail flags aren't being set would be greatly appreciated!
 
Back
Top