여러 카테고리에 제품이 있습니다.제품 카테고리 트리보기 (계층 적보기)
예 :
Category > Books > Hardcover Books > childCategory
Category > Promo Books > Sample > childCategory
제품에 대한 모든 범주의 목록을 가져 오는 데 사용할 수있는 헬퍼 클래스가 있습니까?
여러 카테고리에 제품이 있습니다.제품 카테고리 트리보기 (계층 적보기)
예 :
Category > Books > Hardcover Books > childCategory
Category > Promo Books > Sample > childCategory
제품에 대한 모든 범주의 목록을 가져 오는 데 사용할 수있는 헬퍼 클래스가 있습니까?
제품의 전체 트리 구조를 제공하는 유틸리티 클래스 OOTB에 대해 알지 못합니다. 즉, 이것을 구축하는 것이 그리 어렵지 않습니다.
productId
이 있고 '루트'categoryId
을 알고 있다고 가정하면 CatalogTools
클래스의 확장에 다음 방법을 추가하십시오. 당신이 당신의 사이트에 대한 기초로 CommerceReferenceStore (CRS)를 사용하는 경우
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
에 다음은, 다음 /atg/commerce/catalog/CatalogTools
구성 요소는 atg.commerce.catalog.custom.CustomCatalogTools
를 확장 StoreCatalogTools
클래스를 사용 수업. 그렇지 않으면 CatalogTools
구성 요소가 CustomCatalogTools
클래스를 사용하지 않는 경우 해당 구성 요소가 업데이트되도록 업데이트해야합니다.
다음 method 사용할 수 있습니다 :
public java.util.Collection getProductsCategories(RepositoryItem pProduct,
Repository pCatalogRepository)
throws RepositoryException
당신은 다음과 같은 기본 카탈로그를 사용하여 호출 할 수 있습니다 :
getCatalogTools().getProductsCategories(productItem, getCatalog());
가 의견을 보내 주셔서 감사합니다. 나는 당신의 코드와 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