I have imported 7000 products through an Oscommerce website everything is great except that the imported images are not selected as base image , small image and thumbnail image.
I need to inform you that every product have a single image which will act as base image , small image and thumbnail image.
I am not getting how to do that as it's not possible for me to go to every product and mark the image as base image , small image and thumbnail image.
I have created a script and trying to run it is not giving any error but still not solving the issue.
<?php
require 'app/Mage.php';
Mage::app();
$prod_id = 7068 ;
$_product = Mage::getModel('catalog/product')->load($prod_id);
$prod_img_col = $_product->getMediaGalleryImages();
foreach($prod_img_col as $gallery_img) {
$_product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product'. $gallery_img['file'], array('image', 'thumbnail', 'small_image'), false, false);
}
?>
I hope anyone knows how to do this.
Thanks,
Sarvagya
Best Answer
If you're comfortable with editing the database directly, I can point you in the right direction.
That'll get you all of your products and all of their image attributes. Take note of which attribute has your values. You may need to look at
catalog_product_entity_varchar
directly to get theattribute_id
of the other two image attributes (one ofimage
,small_image
orthumbnail
, probably the latter two).So you could write a PHP script that directly inserts into
catalog_product_entity_varchar
, using the results from the select statement above.