I have below code with save configurable Image. But images are not save pragmatically showing below error

    /*Add Images To The Product*/
    $imagePath = "sample.png"; // path of the image
    $product->addImageToMediaGallery($imagePath, array('image', 'small_image', 'thumbnail'), false, false);


1 exception(s): Exception #0 (Magento\Framework\Exception\InputException): The image content is not valid.

Exception #0 (Magento\Framework\Exception\InputException): The image content is not valid.

0 /var/www/html/awardsideas/vendor/magento/module-catalog/Model/ProductRepository.php(590):

Magento\Catalog\Model\ProductRepository->processMediaGallery(Object(Magento\Catalog\Model\Product\Interceptor), Array)

1 /var/www/html/awardsideas/vendor/magento/framework/Interception/Interceptor.php(58):


  • have u solved this issue? – Wojciech Ka Sep 17 '18 at 14:43

Try this $product->save(); instead of $productRepository->save($product);

  • 1
    sad but true... you have to use the deprecated way cause the core developer give a fck to finish there functions... – ZFNerd Nov 13 '18 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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