Magento – magento 2 rest api : get cart items with images

apicartmagento-2.1magento2rest

In rest api, I am using "/rest/V1/guest-carts/e3e1fd447e0e315dd761942cf949ce5d/items" method to get the magento cart items. It works well and the result is

  [
    {
      "item_id": 100,
      "sku": "abc-1",
      "qty": 1,
      "name": "Product one",
      "price": 19,
      "product_type": "simple",
      "quote_id": "e3e1fd447e0e315dd761942cf949ce5d"
    },
    {
      "item_id": 101,
      "sku": "abc-2",
      "qty": 1,
      "name": "Product two",
      "price": 54,
      "product_type": "simple",
      "quote_id": "e3e1fd447e0e315dd761942cf949ce5d"
    }
]

Now I want get the images of each products in the list(Possibily a thumbnail image). Is there any way to achieve this result?

Best Answer

On my point of view, you have two options

1/

Make other API calls :

  • /rest/V1/products/{sku}

OR

  • /rest/V1/products with search criteria params

You retrieve all product information included images such as :

<custom_attributes>
    <item>
        <attribute_code>thumbnail</attribute_code>
        <value>/m/b/mb01-blue-0.jpg</value>
    </item>
</custom_attributes>

2/

If you need the complete path of the image with Magento cache, you need to create or extend API.

You can based on this related post : Magento 2 Rest Api get Thumbnail Image url

Related Topic