Skip to content

list-crosssell-products

Method: GET
Path: /catalog/products/cross-sell

Tags: Catalog

Summary

Retrieve cross-sell products

Description

Retrieves a list of products specified for cross selling. The cross-sell products are returned based on product ids specified in request param.

Storefront SDK Usage

SDK Method: sdk.catalog.listCrossSellProducts()

Example:

typescript
// Basic usage - get cross-sell products for cart items
const { data, error } = await sdk.catalog.listCrossSellProducts({
  product_id: ["prod_01H9XYZ12345ABCDE", "prod_01H9ABC67890FGHIJ"]
});

// Advanced usage with pagination and custom sorting
const { data, error } = await sdk.catalog.listCrossSellProducts({
  product_id: ["prod_01H9XYZ12345ABCDE"],
  page: 1,
  limit: 10,
  sort_by: '{"price":"asc"}'
});

// Override customer group ID for this specific request
const { data, error } = await sdk.catalog.listCrossSellProducts(
  {
    product_id: ["prod_01H9XYZ12345ABCDE"],
    page: 1,
    limit: 10
  },
  {
    "x-customer-group-id": "01H9XYZ12345USERID" // Override default SDK config
  }
);

if (error) {
  console.error("Failed to get cross-sell products:", error.message);
} else {
  console.log("Cross-sell products found:", data.products.length);
  console.log("Pagination:", data.pagination);

  data.products.forEach(product => {
    console.log(`Product: ${product.name} - ${product.price}`);
  });
}

TypeScript Definition

typescript
"list-crosssell-products": {
        parameters: {
            query?: {
                /** @description no of rows per page */
                limit?: number;
                /** @description page number in pagination */
                page?: number;
                /** @description Product ids of cart items */
                product_id?: string[];
                /** @description json to sort records */
                sort_by?: string;
            };
            header?: {
                /** @description This param is used to determine product pricing, promotions, and subscription rates.  If a valid customer group id is provided, pricing details will be retrieved accordingly.  If no matching data is found for the specified customer group id, the system will fall back to the default customer group id.  If no data is found for the default group either, the highest applicable price will be returned. */
                "x-customer-group-id"?: components["parameters"]["CustomerGroupId"];
            };
            path?: never;
            cookie?: never;
        };
        requestBody?: never;
        responses: {
            /** @description Success response */
            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        content: {
                            products: components["schemas"]["Item"][];
                            pagination: components["schemas"]["Pagination"];
                        };
                    };
                };
            };
            401: components["responses"]["Unauthorized"];
            404: components["responses"]["NotFound"];
        };
    };

Component References

ReferenceResolves To
components["parameters"]["CustomerGroupId"]CustomerGroupId
components["schemas"]["Item"]Item
components["schemas"]["Pagination"]Pagination
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["NotFound"]NotFound

Parameters

  • x-customer-group-id (header): This param is used to determine product pricing, promotions, and subscription rates. If a valid customer group id is provided, pricing details will be retrieved accordingly. If no matching data is found for the specified customer group id, the system will fall back to the default customer group id. If no data is found for the default group either, the highest applicable price will be returned.
  • limit (query): no of rows per page
  • page (query): page number in pagination
  • product_id (query): Product ids of cart items
  • sort_by (query): json to sort records

Responses

200

Success response

401

Not authorized for given operation on the Resource

404

Requested resource not found

OpenAPI Definition

json
{
  "tags": [
    "Catalog"
  ],
  "operationId": "list-crosssell-products",
  "summary": "Retrieve cross-sell products",
  "description": "Retrieves a list of products specified for cross selling. The cross-sell products are returned based on product ids specified in request param.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/list-crosssell-products",
    "description": "API reference for the list-crosssell-products operation"
  },
  "parameters": [
    {
      "$ref": "#/components/parameters/CustomerGroupId"
    },
    {
      "name": "limit",
      "in": "query",
      "description": "no of rows per page",
      "schema": {
        "type": "integer"
      }
    },
    {
      "name": "page",
      "in": "query",
      "description": "page number in pagination",
      "schema": {
        "type": "integer"
      }
    },
    {
      "name": "product_id",
      "in": "query",
      "description": "Product ids of cart items",
      "schema": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    {
      "name": "sort_by",
      "in": "query",
      "description": "json to sort records",
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Success response",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "products": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Item"
                    }
                  },
                  "pagination": {
                    "$ref": "#/components/schemas/Pagination"
                  }
                },
                "required": [
                  "products",
                  "pagination"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "catalog",
  "x-speakeasy-ignore": false,
  "x-speakeasy-name-override": "listCrosssellProducts"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: