Skip to content

REST API page size & current page search criteria options return item(s) past end of data set #8099

Closed
@careys7

Description

@careys7

Preconditions

  1. Magento 2.0.0 - 2.1.3 (Community or Enterprise) with Sample Data installed
  2. Environment using magento2-docker-compose

Steps to reproduce

This issue appears to affect at least /products/ and /categories/ requests. I have added below an example for products.

  1. Make API request for products specifying page size as 1, current page as 99999, eg:
GET /rest/default/V1/products/?searchCriteria[pageSize]=1&searchCriteria[currentPage]=9999 
HTTP/1.1
Host: m2.localhost:8000
Authorization: OAuth oauth_consumer_key="sitoq7tu4b1aj7kikj4irkog8tggh1ch",oauth_token="kr3bly2kbbnrr9flyws9r4mxdaagxngo",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1484095699",oauth_nonce="TivkWr",oauth_version="1.0",oauth_signature="Q02C2wk4AgkDPkYAbACUoLMoXa4%3D"
Cache-Control: no-cache

Note: Page size of '1' above is a nominal value to make examples given below more concise.

Expected result

  1. No items returned in response if (current page * page size) > total products, eg:
{
  "items": [],
  "search_criteria": {
    "filter_groups": [],
    "page_size": 1,
    "current_page": 99999
  },
  "total_count": 2048
}

Actual result

  1. The product with highest id is returned, eg:
{
  "items": [
    {
      "id": 2048,
      "sku": "24-WG085_Group",
      "name": "Set of Sprite Yoga Straps",
      "attribute_set_id": 12,
      "status": 1,
      "visibility": 4,
      "type_id": "grouped",
      "created_at": "2016-11-13 21:24:31",
      "updated_at": "2016-11-13 21:24:31",
      "extension_attributes": [],
      "product_links": [
        {
          "sku": "24-WG085_Group",
          "link_type": "associated",
          "linked_product_sku": "24-WG085",
          "linked_product_type": "simple",
          "position": 0,
          "extension_attributes": {
            "qty": 0
          }
        },
        {
          "sku": "24-WG085_Group",
          "link_type": "associated",
          "linked_product_sku": "24-WG086",
          "linked_product_type": "simple",
          "position": 1,
          "extension_attributes": {
            "qty": 0
          }
        },
        {
          "sku": "24-WG085_Group",
          "link_type": "associated",
          "linked_product_sku": "24-WG087",
          "linked_product_type": "simple",
          "position": 2,
          "extension_attributes": {
            "qty": 0
          }
        }
      ],
      "tier_prices": [],
      "custom_attributes": [
        {
          "attribute_code": "description",
          "value": "<p>Great set of Sprite Yoga Straps for every stretch and hold you need. There are three straps in this set: 6', 8' and 10'.</p>\n<ul>\n<li> 100% soft and durable cotton.\n<li> Plastic cinch buckle is easy to use.\n<li> Choice of three natural colors made from phthalate and heavy metal free dyes.\n</ul>"
        },
        {
          "attribute_code": "image",
          "value": "/l/u/luma-yoga-strap-set.jpg"
        },
        {
          "attribute_code": "small_image",
          "value": "/l/u/luma-yoga-strap-set.jpg"
        },
        {
          "attribute_code": "thumbnail",
          "value": "/l/u/luma-yoga-strap-set.jpg"
        },
        {
          "attribute_code": "options_container",
          "value": "container2"
        },
        {
          "attribute_code": "required_options",
          "value": "0"
        },
        {
          "attribute_code": "has_options",
          "value": "0"
        },
        {
          "attribute_code": "url_key",
          "value": "set-of-sprite-yoga-straps"
        },
        {
          "attribute_code": "is_returnable",
          "value": "2"
        },
        {
          "attribute_code": "activity",
          "value": "17"
        },
        {
          "attribute_code": "material",
          "value": "41,53"
        },
        {
          "attribute_code": "gender",
          "value": "89,90,93"
        },
        {
          "attribute_code": "category_gear",
          "value": "96"
        },
        {
          "attribute_code": "size",
          "value": "100"
        }
      ]
    }
  ],
  "search_criteria": {
    "filter_groups": [],
    "page_size": 1,
    "current_page": 99999
  },
  "total_count": 2048
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Framework/WebapiUSE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseimprovement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions