我有多个类别的产品存在。
示例:
Category > Books > Hardcover Books > childCategory
Category > Promo Books > Sample > childCategory是否有任何辅助类可用于获取产品的所有类别的列表?
发布于 2016-09-27 03:24:40
据我所知,没有任何实用类OOTB可以为您提供产品的完整树结构。也就是说,构建它并不是太困难。
给定一个根,并假设您知道“根”categoryId,将以下方法添加到CatalogTools类的扩展中。
private RqlStatement findParentCategoriesOfProductRQL;
public RepositoryItem[] findParentCategoriesOfProduct(String productId, String rootCategoryId) throws RepositoryException {
RepositoryView view = getCatalog().getView("category");
RepositoryItem[] parentCategories = findParentCategoriesOfProductRQL.executeQuery(view, new Object[] {productId, rootCategoryId });
if (parentCategories == null || parentCategories.length == 0) {
return null;
}
return parentCategories;
}
public void setFindParentCategoriesOfProductRQL(RqlStatement findParentCategoriesOfProduct) {
this.findParentCategoriesOfProductRQL = findParentCategoriesOfProduct;
}
public RqlStatement getFindParentCategoriesOfProductRQL() {
return findParentCategoriesOfProductRQL;
}并将以下内容添加到您的CatalogTools.properties
findParentCategoriesOfProductRQL=fixedChildProducts includes item (id = ?0) AND ancestorCategoryIds includes ?1发布于 2016-09-27 21:58:12
如果您使用CommerceReferenceStore (CRS)作为站点的基础,那么您的/atg/commerce/catalog/CatalogTools组件将使用StoreCatalogTools类,该类扩展了atg.commerce.catalog.custom.CustomCatalogTools类。否则,如果您的CatalogTools组件不使用CustomCatalogTools类,您将需要更新它以使其使用该类。
以下是可用的method:
public java.util.Collection getProductsCategories(RepositoryItem pProduct,
Repository pCatalogRepository)
throws RepositoryException您可以使用默认目录来调用它,如下所示:
getCatalogTools().getProductsCategories(productItem, getCatalog());https://stackoverflow.com/questions/39708549
复制相似问题