@Path("catalog/products/{marketAreaCode}/{categoryCode}")
@Produces(MediaType.APPLICATION_JSON)
public CmsProductsPojo productsByMarketArea(@PathParam("marketAreaCode") final String marketAreaCode, @PathParam("categoryCode") final String categoryCode) {
CmsProductsPojo cmsProducts = new CmsProductsPojo();
MarketAreaPojo selectedMarketArea = marketPojoService.getMarketAreaByCode(marketAreaCode);
if(selectedMarketArea != null){
selectedMarketArea.setMarket(null);
selectedMarketArea.setRetailers(null);
selectedMarketArea.setLocalizations(null);
cmsProducts.setMarketArea(selectedMarketArea);
List<CatalogCategoryPojo> categories = selectedMarketArea.getCatalog().getSortedRootCatalogCategories();
for (Iterator<CatalogCategoryPojo> iterator = categories.iterator(); iterator.hasNext();) {
CatalogCategoryPojo catalogCategoryPojo = (CatalogCategoryPojo) iterator.next();
if(catalogCategoryPojo.getCode().equals(categoryCode)){
List<ProductMarketingPojo> products = catalogCategoryPojo.getProductMarketings();
for (Iterator<ProductMarketingPojo> iteratorProductMarketingPojo = products.iterator(); iteratorProductMarketingPojo.hasNext();) {
ProductMarketingPojo productMarketingPojo = (ProductMarketingPojo) iteratorProductMarketingPojo.next();
productMarketingPojo.setProductBrand(null);
productMarketingPojo.setProductMarketingMarketAreaAttributes(null);
productMarketingPojo.setProductMarketingGlobalAttributes(null);
productMarketingPojo.setProductSkus(null);
productMarketingPojo.setProductAssociationLinks(null);
}
cmsProducts.setProductMarketings(products);
}
}
CatalogPojo catalog = selectedMarketArea.getCatalog();
catalog.setSortedRootCatalogCategories(null);
cmsProducts.setCatalog(catalog);
}