Method addImageToMediaGallery() seems to me buggy, when using productRepository to save product, what encourage us to use deprecate method save() directly from product model (what causes other bugs), when trying to add product programatically. What is the correct way to add image, what classes should I use in order to perform it using repository. I have added question here in comments (accepted answer seems to provide some general clues), but I think this subject deserves separte question, as stack and internet tutorials are full of deprecate code. Some real example of code would be extremely useful.


I have found an answer - it can be done using other object - example here

  • you need to share your code here, what you have try. – Dhiren Vasoya Jan 2 '17 at 5:57
  • I want to create product programatically and add an image to it, not using addImageToMediaGallery() – Bartosz Kubicki Jan 2 '17 at 7:25
  • I am asking to share your code. – Dhiren Vasoya Jan 2 '17 at 9:07
  • I know what you asking, but it doesn't matter - I ask just for GENERAL way of adding image without using mentioned method. So it should work with any code. Product data can be example – Bartosz Kubicki Jan 2 '17 at 9:12
  • Then you need to create another attribute and upload image into that and then show that attribute value every where. – Dhiren Vasoya Jan 2 '17 at 9:16

Your Answer

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

Browse other questions tagged or ask your own question.