Class AbstractCategoriesRetriever

    • Field Detail

      • categoryQueryHook

        protected Consumer<com.adobe.cq.commerce.magento.graphql.CategoryTreeQuery> categoryQueryHook
        Lambda that extends the category query.
      • categories

        protected List<com.adobe.cq.commerce.magento.graphql.CategoryTree> categories
        List of category instances. Is only available after populate() was called.
      • identifiers

        protected List<String> identifiers
        Identifiers of the categories that should be fetched. Which kind of identifier is used (usually id) is implementation specific and should be checked in subclass implementations.
      • identifierType

        protected UrlProvider.CategoryIdentifierType identifierType
        Identifiers of the categories that should be fetched. Which kind of identifier is used (usually id) is implementation specific and should be checked in subclass implementations.
    • Constructor Detail

    • Method Detail

      • fetchCategories

        public List<com.adobe.cq.commerce.magento.graphql.CategoryTree> fetchCategories()
        Executes the GraphQL query and returns categories. For subsequent calls of this method, a cached list of categories is returned.
        Returns:
        List of categories
      • setIdentifiers

        public void setIdentifiers​(List<String> identifiers)
        Set the identifiers of the categories that should be fetched. Which kind of identifier is used (usually id) is implementation specific and should be checked in subclass implementations. Setting the identifiers, removes any cached data.
        Parameters:
        identifiers - Category identifiers
      • setIdentifiers

        public void setIdentifiers​(List<String> identifiers,
                                   UrlProvider.CategoryIdentifierType identifierType)
        Set the identifiers and identifier types of the categories that should be fetched Setting the identifiers, removes any cached data.
        Parameters:
        identifiers - Category identifiers
        identifierType - Which kind of identifier is used: ID, UID
      • extendCategoryQueryWith

        public void extendCategoryQueryWith​(Consumer<com.adobe.cq.commerce.magento.graphql.CategoryTreeQuery> categoryQueryHook)
        Extend the category query part of the category GraphQL query with a partial query provided by a lambda hook that sets additional fields. Example:
         
         categoryRetriever.extendCategoryQueryWith(p -> p
             .level());
         
         
        Parameters:
        categoryQueryHook - Lambda that extends the category query
      • generateCategoryQuery

        protected abstract com.adobe.cq.commerce.magento.graphql.CategoryTreeQueryDefinition generateCategoryQuery()
        Generates the partial CategoryTree query part of the GraphQL category query.
        Returns:
        CategoryTree query definition
      • generateQuery

        protected String generateQuery​(List<String> identifiers)
        Generates a complete category GraphQL query with a selection of the given category identifiers.
        Parameters:
        identifiers - Category identifiers, usually the category id
        Returns:
        GraphQL query as string
      • executeQuery

        protected com.adobe.cq.commerce.graphql.client.GraphqlResponse<com.adobe.cq.commerce.magento.graphql.Query,​com.adobe.cq.commerce.magento.graphql.gson.Error> executeQuery()
        Execute the GraphQL query with the GraphQL client.
        Specified by:
        executeQuery in class AbstractRetriever
        Returns:
        GraphqlResponse object