Image is not setting as base/thumbnail after creating product programmatically
-
05-10-2020 - |
Question
I'm trying to set product image while creating product programmatically(on server). The image which I'm trying to set as product image is getting uploaded after product creation but it is not setting as base/small/thumbnail image.
Using below code, first I'm initialising media gallery and then adding image.And the same set of code is working in localhost not on server.On server I've changed directory permissions as well.
...
->setMediaGallery(array('images' => array(), 'values' => array())) //media gallery initialization
->addImageToMediaGallery('full path', array('image','thumbnail','small_image'), false, false)
...
As I'm not getting any exception because image is getting uploaded. Is it because of directory/file permissions. Guys, help me to figure out what exactly the issue.
La solution
Finally after more than 1 day of struggling found the issue of not setting image as base/small/thumbnail
.Because of attribute scope. In my magento store the attributes image
,small_image
and thumbnail
were set to Store View(Scope
). After changing the scope
of these attributes, I'm able to set images to product programmatically.