Skip to main content
More in Learn

Retrieving Price List Info from the Catalogue

Because price lists are associated with product variants in your catalogue, you can retrieve information about them via the Catalogue API.

Here’s an example of fetching detailed information for all English-language products in the catalogue, including price list information:

query {
  catalogue(path: "/", language: "en") {
    id
    path
    children {
      id
      name
      path
      ... on Product {
        variants {
          sku
          name
          price
          
          priceVariants {
                identifier
                name
                price
                currency
            
                priceForEveryone {
                      identifier
                      price
                          startDate
                      endDate
                }
            
                priceFor(marketIdentifiers: ["students"]) {
                      identifier
                      price
                      startDate
                      endDate
                }
            
            priceList(identifier: "price-list-for-students") {
                  identifier
                  price
            }
          }
        }
      }
    }
  }
}

Let’s break this down …

priceVariants {
                identifier
                name
                price
                currency
            
                priceForEveryone {
                      identifier
                      price
                      startDate
                      endDate
                }
            
                priceFor(marketIdentifiers: ["students"]) {
                      identifier
                      price
                      startDate
                      endDate
                }

Within priceVariants, you can use priceForEveryone to return the best price from price lists that target all customers and markets. If the variant’s base price happens to be cheaper, that will be returned instead.

If you need pricing information for specific markets, you can use priceFor and pass in one or more market identifiers. priceFor will return the lowest price for any of them.

Finally, you can fetch the price for a given price list with the priceList property by passing in the price list’s identifier:

priceList(identifier: "price-list-for-students") {
    identifier
    price
}

Retrieving a Single Price Variant

Instead of using priceVariants to retrieve an array of price variants, you can use priceVariant to retrieve a single price variant based on its identifier. If no such variant exists, its associated fields will be null.

query { 
  catalogue(
    path: "/"
    language: "en"
   ) {
      id
      path
      children {
        ...on Product {
          variants {
          priceVariant(identifier: "eur") { # returns one entry of price variants, or null
            identifier
            name
            price
            currency
          }
           }
       }
    }
  }
}

Fetching the Product Variants Subject To a Price List

It’s also possible to fetch a price list and return the variants associated with it. The example below paginates the variants that are returned.

query {
  priceList(identifier: "price-list-for-students") {
    tenantId
    identifier
    name
    modifierType
products (
language: "en"
      after: "eyJfaWQiOiI2MWMzMTE5YWZjZDE1MDZmODdjYmQwOWMifQ=="
      #first: 2
) {
pageInfo {
        hasPreviousPage
        hasNextPage
        startCursor
        endCursor
        totalNodes
}
edges {
        cursor
        node {
          id
          type
          name
          variants {
            sku
            price
            priceVariants {
              identifier
              name
              currency
              price
              priceList (identifier: "price-list-for-students") {
                startDate
                endDate
                identifier
                price
              }
            }
          }
        }
      }
    }
  }
}

For further details, please refer to the API docs accessible from the GraphQL playground for the Catalogue API (https://api.crystallize.com/{your-tenant-name}/catalogue).

People showing thumbs up

Need further assistance?

Ask the Crystallize team or other enthusiasts in our slack community.

Join our slack community