1

The response does not have the "category_ids" key. I need this key. Is there any other API which can provide this key?

  "id": 10,
  "sku": "Nike 3 color half sleeve tshirt",
  "name": "Nike 3 color half sleeve tshirt",
  "attribute_set_id": 4,
  "price": 0,
  "status": 1,
  "visibility": 4,
  "type_id": "configurable",
  "created_at": "2015-12-01 23:05:47",
  "updated_at": "2015-12-25 00:22:27",
  "weight": 2,
  "product_links": [],
  "options": [],
  "tier_prices": [],
  "custom_attributes": [
    {
      "attribute_code": "description",
      "value": "<p>Nike summer wear hal sleeve tshirt in 3 colors</p>"
    },
    {
      "attribute_code": "meta_title",
      "value": "Nike 3 color half sleeve tshirt"
    },
    {
      "attribute_code": "meta_keyword",
      "value": "Nike 3 color half sleeve tshirt"
    },
    {
      "attribute_code": "meta_description",
      "value": "Nike 3 color half sleeve tshirt <p>Nike summer wear hal sleeve tshirt in 3 colors</p>"
    },
    {
      "attribute_code": "image",
      "value": "/p/w/pwp_sheet2.jpeg"
    },
    {
      "attribute_code": "small_image",
      "value": "/p/w/pwp_sheet2.jpeg"
    },
    {
      "attribute_code": "thumbnail",
      "value": "/p/w/pwp_sheet2.jpeg"
    },
    {
      "attribute_code": "options_container",
      "value": "container2"
    },
    {
      "attribute_code": "required_options",
      "value": "1"
    },
    {
      "attribute_code": "has_options",
      "value": "1"
    },
    {
      "attribute_code": "url_key",
      "value": "nike-3-color-half-sleeve-tshirt"
    },
    {
      "attribute_code": "tax_class_id",
      "value": "2"
    },
    {
      "attribute_code": "vendor",
      "value": "Paxcel Cloth House"
    }
  ]
1

category_ids is not joined when list of products is loaded. There are two options to get it:

  1. Get list of product IDs, then load each one separately (when requesting GET rest/V1/products/:sku, category_ids attribute is loaded)
  2. Add plugin for \Magento\Catalog\Api\ProductRepositoryInterface::getList which will populate it
  • Hey, can you elaborate on how to add a plugin? – nr5 Dec 30 '15 at 7:54
  • 1
    Take a look at the official docs – Alex Paliarush Dec 30 '15 at 9:36
  • hi, as per the documentation I have to modify the di.xml file of a particular module. I found the di.xml in \Magento\Catalog\Api\di.xml directory. Is this the one.. – nr5 Dec 31 '15 at 10:06
  • You can create di.xml in your custom module, eventually di.xml from all modules are collected and merged together (by areas). It is not a good idea to modify core files because this will cause problems during upgrade. – Alex Paliarush Dec 31 '15 at 10:09
  • 2
    That one is for Magento 1, better to search for 'plugin' in core di.xml files and check how it is implemented there. Also look at this and this – Alex Paliarush Dec 31 '15 at 12:25

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.