Мне неизвестны какие-либо служебные классы 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
Спасибо за обратную связь. Я буду изучать ваш код и CatalogTools. – dreboy
Есть ли способ сделать это только с помощью инструментов «Каталог»? http://docs.oracle.com/cd/E52191_01/Platform.11-1/apidoc/atg/commerce/catalog/CatalogTools.html#getAncestors(atg.repository.RepositoryItem) – dreboy
Из документов, похоже, что это возможно что ты хочешь. Возможно, спуститесь на один класс в класс 'CustomCatalogTools' и посмотрите, что он там предлагает. Может быть, более конкретным. http://docs.oracle.com/cd/E52191_01/Platform.11-1/apidoc/atg/commerce/catalog/custom/CustomCatalogTools.html#getAncestors(atg.repository.RepositoryItem) – radimpe