0

I've created a script to import many hundred products from another datasource via SOAP to magento but I want to use the same product image for all products. Is this possible?

2
  • do you want to import one image same for all products ? Aug 2, 2016 at 12:57
  • yes that's exactly what I want to do.
    – Alex
    Aug 2, 2016 at 13:21

1 Answer 1

0

Place your product image at /media/import/folder. and rest code will handle

$client = new SoapClient('http://yourmagentohost.com/index.php/api/v2_soap?wsdl=1');
$session = $client->login('yourapiusername','yourapipassword');
$name = $product->getName()
$download_path = "/home/magento/media/imports/" . $file_name; // path to media/import/
$content = base64_encode(file_get_contents($file));
$newFile = array(
    'content' => $content,
    'mime' => 'image/jpeg'
);
$client->catalogProductAttributeMediaCreate(
    $session, $productId, array('file' => $newFile, 'label' => $name, 'position' => '50', 'types' => array('image', 'small_image', 'thumbnail'), 'exclude' => 0)
);
1
  • Thanks but with this solution the same image will be upload again for each product, right? is it possible that all of the products have the same img path?
    – Alex
    Aug 4, 2016 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.