I'm trying to create a web service rest to add an image to category, but I can't find the Model method that allow to do this.

I'm looking for something like

addImage of Magento\Catalog\Model\Product\Gallery\Processor

for the category.



For category, by default, seem that we cannot do the same, however, we can add the image like this:

/** @var \Magento\Catalog\Model\Category $category **/

    ->setName('Category 1.1.1')

With API (not yet test)

/** @var \Magento\Catalog\Api\CategoryRepositoryInterface $category **/

  • Thanks for the answer @Khoa, the path on setThumbnail method is yuor local path or the image have to be uploaded before on magento? – 3tech - Alessandro Staffolani Sep 15 '16 at 7:23
  • The image have to be uploaded before on Magento. – Khoa TruongDinh Sep 15 '16 at 7:26
  • This is a problem, because I'm creating a webservice to allow third part to upload the images and data of categories. So the method need also to upload the image from custom path – 3tech - Alessandro Staffolani Sep 15 '16 at 7:30
  • 1
    I got the soluction, for categories to upload images it's only necessary put them in the right folder and set the name on image attribute. – 3tech - Alessandro Staffolani Sep 15 '16 at 8:20
  • Yeah! You can edit my answer or answer your own question. – Khoa TruongDinh Sep 15 '16 at 8:21

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.