Rishu Singh
Rishu Singh

Reputation: 303

import images via configurable csv

I want to import Configurable Product along with their associative products and images. I imported the products it associative products are coming in configurable product but images are not uploaded for product. can anyone help me out??

Upvotes: 2

Views: 64

Answers (1)

Mohd Miraj
Mohd Miraj

Reputation: 96

First save your product with all data without images, then load your product by sku

$image = 'abc.jpg';
$importDir = Mage::getBaseDir('media') . DS . 'import/'; //put your images in this folder 
$imgpath = $importDir.$image;

$ConfigproductImg = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku); //load product by sku
$simpleproductImg->setMediaGallery(array('images' => array(), 'values' => array()));//
$simpleproductImg->addImageToMediaGallery($imgpath, array('image','thumbnail','small_image'), false, false); // set images to media gallery
$simpleproductImg->save(); //save product

Upvotes: 1

Related Questions