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", "max-age": 0 }, "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: