Skip to content

getProductsInCollection(int collection_id, int items_per_page)

The getProductsInCollection method is used to get the ProductsList object that represents a list of products in given collection. Method requires collection id parameter.

Input parameters

collection_id

int Id of collection of products. Parameter is required.

items_per_page

int Number of items in a page of internal paginator. Parameter is optional. Default value is 16.

Returned value

The ProductsList object.

Example

source
{% set collectionId = 123 %}
{% set products = ObjectApi.getProductsInCollection(collectionId) %}

{% if products is not empty %}
    <p>Products in the collection with id = {{ collectionId }}:</p>
    {% for product in products %}
        <p>{{ product.name }}</p>
    {% endfor %}
{% endif %}
output
<p>Products in the collection with id = 123:</p>
<p>Samsung S10</p>
<p>Corn Flakes 500g</p>