Category Module
Configurations
You can set the templates for the category single view (if it should be different from default)
# default template
commerce.category.view.template: "category/category"
# template used for category type "teaser"
commerce.category.view.teaserTemplate: "category/teaser"
Usage in templates
This module provides two data controller that can be used to get category and tree objects:
- var rootCategoryTree = data('category.tree', {'code': ''})
each category in rootCategoryTree.categories
- var category = data("category",{'code': 'category-code'})
Dependencies:
- product package: (for product searchservice)
- search package: (for pagination)
GraphQL
This module offers GraphQL Shema and Resolver to get Categories.
Example:
query category {
Commerce_Category(categoryCode:"flat-screen_tvs") {
category {
code
attributes {
all {code}
metaKeywords:get(code:"meta_keywords") {values{value}}
hasMetaKeywords: has(code:"meta_keywords")
}
}
productSearchResult {
products {
baseData {title}
}
}
}
}
Category tree from config
The module comes also with a Adapter for the secondary port "CategoryService" which can be activated by setting commerce.category.useCategoryFixedAdapter: true
You can then configure a category tree like in the example below.
(Of course this is only useful for small tests or demos)
commerce:
category:
useCategoryFixedAdapter: true
categoryServiceFixed:
tree:
electronics:
code: electronics
name: Electronics
sort: 1
childs:
flat-screen_tvs:
code: flat-screen_tvs
name: Flat Screens & TV
headphones:
code: headphones
name: Headphones
childs:
headphone_accessories:
code: headphone_accessories
name: Accessories
tablets:
code: tablets
name: Tablets
clothing:
code: clothing
name: Clothes & Fashion
sort: 2