Magento 1.7 – Set Image as Base, Small, and Thumbnail

avs-fastsimpleimportimageimportmagento-1.7

So I am constructing an import array with details and using AvS_FastSimpleImport to do the importing work. Here is the relevant code:

$fileName = Mage::getBaseDir()."/".Mage::getStoreConfig(C4B_XmlImport_Model_Catalog_Importer::XML_PATH_IMAGE_IMPORT_DIRECTORY).$imageName;
            if (file_exists($fileName)) {
                $addImage = $defaultImportEntry;
                $addImage['sku'] = '';
                $addImage['_media_image'] = $imageName;
                $addImage['_media_attribute_id'] = Mage::getSingleton('catalog/product')->getResource()->getAttribute('media_gallery')->getAttributeId();
                $addImage['_media_is_disabled'] = 0;
                $addImage['_media_position'] = $imgCounter;
                $addImage['_media_lable'] = $imageName;
                if(!$isAssociatedProduct && $currentNumber == 1) {
                    $addImage['image'] = $fileName;
                    $addImage['small_image'] = $fileName;
                    $addImage['thumbnail'] = $fileName;
                    }
            }

The second if statement is entered only for specific images (as you can see). On these images I want the radio buttons of Base Image, Small Image, and Thumbnail to be set, but apparently it doesn't work.

Here's a tutorial document I was reading: http://www.integer-net.de/download/ImportExport_EN.pdf

Best Answer

The value in image, small_image and thumbnail should be the same as in _media_image. You should use $imageName instead of $fileName there.

Related Topic