Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Lists

Lists

A list is a collection resource that returns ordered links to other resources.

Cortex lists follow this format:
  • An element link for each resource in the list.

  • A type set to elasticpath.collections.links. This type indicates there are no properties associated with the list, only links to other resources.

Lists Example: lineitems

lineitems are a list resource that contain links to each lineitem in the shopper's cart. In the lineitems resource, each lineitem is represented as an element link with a type set to elasticpath.collections.links:
{
  "self": {
    "type": "elasticpath.collections.links",
    "uri": "/commerce-legacy/carts/mobee/guz=/lineitems",
    "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems"
  },
  "links": [
    {
      "rel": "element",
      "rev": "list",
      "type": "elasticpath.carts.line-item",
      "uri": "/commerce-legacy/carts/mobee/guz=/lineitems/hfq=",
      "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems/hfq="
    },
    {
      "rel": "element",
      "rev": "list",
      "type": "elasticpath.carts.line-item",
      "uri": "/commerce-legacy/carts/mobee/guz=/lineitems/gbq=",
      "href": "http://api.elasticpath.net/cortex/carts/mobee/guz=/lineitems/gbq="
    },
    {
      "rel": "cart",
      "rev": "lineitems",
      "type": "elasticpath.carts.cart",
      "uri": "/commerce-legacy/carts/mobee/guz=",
      "href": "http://api.elasticpath.net/cortex/carts/mobee/guz="
    }
  ]
}

Pagination

Lists can be paginated when large numbers of links return.

Cortex paginated lists follow this format:
  • An element link for each resource on a page.
  • A next link to retrieve the next page of links.
  • A previous link to retrieve the previous page of links.
  • A type set to elasticpath.collections.pagination, which indicates the list is paginated.
  • A pagination object with the following fields:
    • current: The current page number.
    • page-size: The number of links on each page, excluding the next/previous pagination links.
    • pages: The total number of pages.
    • results: The total number of links, excluding the next/previous pagination links.
    • results-on-page: The number of links on the current page, excluding the next/previous pagination links.

Lists Pagination Example: Item Keyword Search

An item keyword search returns a paginated list resource that links to each item found by the keyword search:
{
  "self": {
    "type": "elasticpath.collections.pagination",
    "uri": "/commerce-legacy/searches/mobee/keywords/items/m43g=/pages/2",
    "href": "http://api.elasticpath.net/cortex/searches/mobee/keywords/items/m43g=/pages/2"
  },
  "pagination": {
    "current": 2,
    "page-size": 5,
    "pages": 6,
    "results": 29,
    "results-on-page": 5
  },
  "links": [
    {
      "rel": "element",
      "type": "elasticpath.items.item",
      "uri": "/commerce-legacy/items/mobee/m5yi=",
      "href": "http://api.elasticpath.net/cortex/items/mobee/m5yi="
    },
    {
      "rel": "element",
      "type": "elasticpath.items.item",
      "uri": "/commerce-legacy/items/mobee/m5ypi=",
      "href": "http://api.elasticpath.net/cortex/items/mobee/m5ypi="
    },
    {
      "rel": "element",
      "type": "elasticpath.items.item",
      "uri": "/commerce-legacy/items/mobee/m5yq=",
      "href": "http://api.elasticpath.net/cortex/items/mobee/m5yq="
    },
    {
      "rel": "element",
      "type": "elasticpath.items.item",
      "uri": "/commerce-legacy/items/mobee/m5ya=",
      "href": "http://api.elasticpath.net/cortex/items/mobee/m5ya="
    },
    {
      "rel": "element",
      "type": "elasticpath.items.item",
      "uri": "/commerce-legacy/items/mobee/m5y6=",
      "href": "http://api.elasticpath.net/cortex/items/mobee/m5y6="
    },
    {
      "rel": "previous",
      "type": "elasticpath.collections.pagination",
      "uri": "/commerce-legacy/searches/mobee/keywords/items/m43g=/pages/1",
      "href": "http://api.elasticpath.net/cortex/searches/mobee/keywords/items/m43g=/pages/1"
    },
    {
      "rel": "next",
      "type": "elasticpath.collections.pagination",
      "uri": "/commerce-legacy/searches/mobee/keywords/items/m43g=/pages/3",
      "href": "http://api.elasticpath.net/cortex/searches/mobee/keywords/items/m43g=/pages/3"
    }
  ]
}