magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.47k stars 9.28k forks source link

[REST API] catalogProductRepositoryV1 > GET /V1/products No options array in the response body for items #10699

Closed R3viewer closed 5 years ago

R3viewer commented 7 years ago

Preconditions

  1. Configuration : Magento 2.1.8 CE with sample data
  2. php7.0
  3. Ubuntu 16.04
  4. MYSQL ver 14.14 distrib 5.7.19
  5. Apache 2.4.18

Steps to reproduce

  1. Get admin token with REST API : http://\/rest/default/V1/integration/admin/token
  2. Get product list with Rest API : http://\/rest/default/V1/products?searchCriteria%5BpageSize%5D=1

Expected result

According to Swagger documentation in static and local, normally I must have the following result :

{
  "items": [
    {
      "id": 1,
      "sku": "24-MB01",
      "name": "Joust Duffle Bag",
      "attribute_set_id": 15,
      "price": 34,
      "status": 1,
      "visibility": 4,
      "type_id": "simple",
      "created_at": "2017-08-01 14:39:31",
      "updated_at": "2017-08-03 14:05:52",
      "extension_attributes": {
        "stock_item": {
          "item_id": 1,
          "product_id": 1,
          "stock_id": 1,
          "qty": null,
          "is_in_stock": false,
          "is_qty_decimal": false,
          "show_default_notification_message": false,
          "use_config_min_qty": true,
          "min_qty": 0,
          "use_config_min_sale_qty": 1,
          "min_sale_qty": 1,
          "use_config_max_sale_qty": true,
          "max_sale_qty": 10000,
          "use_config_backorders": true,
          "backorders": 0,
          "use_config_notify_stock_qty": true,
          "notify_stock_qty": 1,
          "use_config_qty_increments": true,
          "qty_increments": 0,
          "use_config_enable_qty_inc": true,
          "enable_qty_increments": false,
          "use_config_manage_stock": true,
          "manage_stock": true,
          "low_stock_date": "2017-08-03 14:05:52",
          "is_decimal_divided": false,
          "stock_status_changed_auto": 1
        }
      },
      "product_links": [],
      "options": [
        {
          "product_sku": "24-MB01",
          "option_id": 1,
          "title": "Test Option",
          "type": "checkbox",
          "sort_order": 1,
          "is_require": false,
          "max_characters": 0,
          "image_size_x": 0,
          "image_size_y": 0,
          "values": [
            {
              "title": "option test ",
              "sort_order": 1,
              "price": 300,
              "price_type": "fixed",
              "sku": "24-MB01+",
              "option_type_id": 1
            }
          ]
        }
      ],
      "media_gallery_entries": [
        {
          "id": 1,
          "media_type": "image",
          "label": "Image",
          "position": 1,
          "disabled": false,
          "types": [
            "image",
            "small_image",
            "thumbnail"
          ],
          "file": "/m/b/mb01-blue-0.jpg"
        }
      ],
      "tier_prices": [],
      "custom_attributes": [
        {
          "attribute_code": "description",
          "value": "<p>The sporty Joust Duffle Bag can't be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places to go.<p>\r\n<ul>\r\n<li>Dual top handles.</li>\r\n<li>Adjustable shoulder strap.</li>\r\n<li>Full-length zipper.</li>\r\n<li>L 29\" x W 13\" x H 11\".</li>\r\n</ul>"
        },
        {
          "attribute_code": "image",
          "value": "/m/b/mb01-blue-0.jpg"
        },
        {
          "attribute_code": "small_image",
          "value": "/m/b/mb01-blue-0.jpg"
        },
        {
          "attribute_code": "thumbnail",
          "value": "/m/b/mb01-blue-0.jpg"
        },
        {
          "attribute_code": "color",
          "value": "49"
        },
        {
          "attribute_code": "category_ids",
          "value": [
            "3",
            "4"
          ]
        },
        {
          "attribute_code": "options_container",
          "value": "container2"
        },
        {
          "attribute_code": "required_options",
          "value": "0"
        },
        {
          "attribute_code": "has_options",
          "value": "1"
        },
        {
          "attribute_code": "msrp_display_actual_price_type",
          "value": "0"
        },
        {
          "attribute_code": "url_key",
          "value": "joust-duffle-bag"
        },
        {
          "attribute_code": "gift_message_available",
          "value": "0"
        },
        {
          "attribute_code": "tax_class_id",
          "value": "2"
        },
        {
          "attribute_code": "eco_collection",
          "value": "0"
        },
        {
          "attribute_code": "performance_fabric",
          "value": "0"
        },
        {
          "attribute_code": "erin_recommends",
          "value": "0"
        },
        {
          "attribute_code": "new",
          "value": "0"
        },
        {
          "attribute_code": "sale",
          "value": "0"
        }
      ]
    }
  ],
  "search_criteria": {
      "filter_groups": [],
      "page_size": 1
    },
    "total_count": 2046
}

Actual result

But when I test with a php code, Rest client or local Swagger I have this :

{
  "items": [
    {
      "id": 1,
      "sku": "24-MB01",
      "name": "Joust Duffle Bag",
      "attribute_set_id": 15,
      "price": 34,
      "status": 1,
      "visibility": 4,
      "type_id": "simple",
      "created_at": "2017-08-01 14:39:31",
      "updated_at": "2017-08-03 14:05:52",
      "extension_attributes": [],
      "product_links": [],
      "tier_prices": [],
      "custom_attributes": [
        {
          "attribute_code": "description",
          "value": "<p>The sporty Joust Duffle Bag can't be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places to go.<p>\r\n<ul>\r\n<li>Dual top handles.</li>\r\n<li>Adjustable shoulder strap.</li>\r\n<li>Full-length zipper.</li>\r\n<li>L 29\" x W 13\" x H 11\".</li>\r\n</ul>"
        },
        {
          "attribute_code": "image",
          "value": "/m/b/mb01-blue-0.jpg"
        },
        {
          "attribute_code": "small_image",
          "value": "/m/b/mb01-blue-0.jpg"
        },
        {
          "attribute_code": "thumbnail",
          "value": "/m/b/mb01-blue-0.jpg"
        },
        {
          "attribute_code": "color",
          "value": "49"
        },
        {
          "attribute_code": "options_container",
          "value": "container2"
        },
        {
          "attribute_code": "required_options",
          "value": "0"
        },
        {
          "attribute_code": "has_options",
          "value": "1"
        },
        {
          "attribute_code": "msrp_display_actual_price_type",
          "value": "0"
        },
        {
          "attribute_code": "url_key",
          "value": "joust-duffle-bag"
        },
        {
          "attribute_code": "gift_message_available",
          "value": "0"
        },
        {
          "attribute_code": "tax_class_id",
          "value": "2"
        },
        {
          "attribute_code": "eco_collection",
          "value": "0"
        },
        {
          "attribute_code": "performance_fabric",
          "value": "0"
        },
        {
          "attribute_code": "erin_recommends",
          "value": "0"
        },
        {
          "attribute_code": "new",
          "value": "0"
        },
        {
          "attribute_code": "sale",
          "value": "0"
        }
      ]
    }
  ],
  "search_criteria": {
    "filter_groups": [],
    "page_size": 1
  },
  "total_count": 2046
}

In this response the "extension_attributes" is empty and the "options" and "media_gallery_entries" array are missing.

Is it a bug in the swagger documentation or a bug in the API ? Personally I would like this information to be present in the product list.

magento-engcom-team commented 7 years ago

@Black-KraKen thank you for your bug report. We've created internal ticket MAGETWO-75300 to track progress on the issue

rogyar commented 6 years ago

I believe that loading extension attributes will have a huge performance impact in case of product list loading. So, that's the main reason why the extension attributes are not loaded. As for the media library, it's easy to add this part to the response. If it makes sense, I can handle it. Thanks

thiagolima-bm commented 6 years ago

I am working on it at #mm17es

Peekmo commented 6 years ago

Hello,

Any update of this ? I really need this extension_attributes and I didn't figured out how to load them in a custom route. Is it something that you plan to fix ? If not (because of performance issues), it should be remove from the documentation and could you please tell me how to add them by ourselves if we really want to have them ?

Regards, Peekmo

magento-engcom-team commented 5 years ago

Hi @engcom-backlog-tomash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

ghost commented 5 years ago

@guperez, thank you for contribution. I can confirm that media_gallery_entries, options, media_gallery_entries are present and not empty if they are set on 2.3.0 with sample data installed. We are closing this issue as fixed because it is not reproducible in the latest released Magento.

kirtinariya1 commented 5 years ago

I am facing same issue in Magento ver. 2.3.0 Any idea what fixed are done in particular case.

DutchPrince commented 3 years ago

I have the same issue