use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class CategoryBreadcrumbServiceExtensionHandler method addParentCrumbs.
/**
* Add the parent crumb for the passed in category.
* Recursively call to find all parents.
*
* @param parentCrumbs
* @param category
* @param url
* @param params
*/
protected void addParentCrumbs(List<BreadcrumbDTO> parentCrumbs, Category category, String url, Map<String, String[]> params) {
Category parentCategory = category.getParentCategory();
if (parentCategory != null && !parentCrumbs.contains(parentCategory)) {
// prevent recursion
BreadcrumbDTO dto = buildCrumbForCategory(parentCategory, url, params);
parentCrumbs.add(0, dto);
addParentCrumbs(parentCrumbs, parentCategory, url, params);
}
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class CategoryBreadcrumbServiceExtensionHandler method modifyBreadcrumbList.
public ExtensionResultStatusType modifyBreadcrumbList(String url, Map<String, String[]> params, ExtensionResultHolder<List<BreadcrumbDTO>> holder) {
// ProductBreadcrumb Handler strips off the productId and last fragment
String testUrl = (String) holder.getContextMap().get(BreadcrumbServiceExtensionManager.CONTEXT_PARAM_STRIPPED_URL);
if (StringUtils.isEmpty(testUrl)) {
testUrl = url;
}
Category category = determineFirstCategory(testUrl, params, holder);
if (category != null) {
BreadcrumbDTO categoryCrumb = buildCrumbForCategory(category, url, params);
BreadcrumbDTO categorySearchCrumb = buildCategorySearchCrumb(category, url, params);
List<BreadcrumbDTO> parentCrumbs = new ArrayList<BreadcrumbDTO>();
addParentCrumbs(parentCrumbs, category, url, params);
if (categorySearchCrumb != null) {
holder.getResult().add(0, categorySearchCrumb);
}
if (categoryCrumb != null) {
holder.getResult().add(0, categoryCrumb);
}
if (!parentCrumbs.isEmpty()) {
holder.getResult().addAll(0, parentCrumbs);
}
}
return ExtensionResultStatusType.HANDLED_CONTINUE;
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class CategoryHandlerMapping method findCategoryUsingUrl.
protected Category findCategoryUsingUrl(HttpServletRequest request) throws UnsupportedEncodingException {
String requestUri = URLDecoder.decode(BLCRequestUtils.getRequestURIWithoutContext(request), charEncoding);
Category category = catalogService.findCategoryByURI(requestUri);
if (category != null && LOG.isDebugEnabled()) {
LOG.debug("Obtained the category using URI=" + requestUri);
}
return category;
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class OrderItemServiceImpl method createBundleOrderItem.
@Override
public BundleOrderItem createBundleOrderItem(final ProductBundleOrderItemRequest itemRequest, boolean saveItem) {
ProductBundle productBundle = itemRequest.getProductBundle();
BundleOrderItem bundleOrderItem = (BundleOrderItem) orderItemDao.create(OrderItemType.BUNDLE);
bundleOrderItem.setQuantity(itemRequest.getQuantity());
bundleOrderItem.setCategory(itemRequest.getCategory());
bundleOrderItem.setSku(itemRequest.getSku());
bundleOrderItem.setName(itemRequest.getName());
bundleOrderItem.setProductBundle(productBundle);
bundleOrderItem.setOrder(itemRequest.getOrder());
if (itemRequest.getSalePriceOverride() != null) {
bundleOrderItem.setSalePriceOverride(Boolean.TRUE);
bundleOrderItem.setSalePrice(itemRequest.getSalePriceOverride());
bundleOrderItem.setBaseSalePrice(itemRequest.getSalePriceOverride());
}
if (itemRequest.getRetailPriceOverride() != null) {
bundleOrderItem.setRetailPriceOverride(Boolean.TRUE);
bundleOrderItem.setRetailPrice(itemRequest.getRetailPriceOverride());
bundleOrderItem.setBaseRetailPrice(itemRequest.getRetailPriceOverride());
}
for (SkuBundleItem skuBundleItem : productBundle.getSkuBundleItems()) {
Product bundleProduct = skuBundleItem.getBundle();
Sku bundleSku = skuBundleItem.getSku();
Category bundleCategory = null;
if (itemRequest.getCategory() != null) {
bundleCategory = itemRequest.getCategory();
}
if (bundleCategory == null && bundleProduct != null) {
bundleCategory = bundleProduct.getDefaultCategory();
}
DiscreteOrderItemRequest bundleItemRequest = new DiscreteOrderItemRequest();
bundleItemRequest.setCategory(bundleCategory);
bundleItemRequest.setProduct(bundleProduct);
bundleItemRequest.setQuantity(skuBundleItem.getQuantity());
bundleItemRequest.setSku(bundleSku);
bundleItemRequest.setItemAttributes(itemRequest.getItemAttributes());
bundleItemRequest.setSalePriceOverride(skuBundleItem.getSalePrice());
bundleItemRequest.setBundleOrderItem(bundleOrderItem);
DiscreteOrderItem bundleDiscreteItem = createDiscreteOrderItem(bundleItemRequest);
bundleDiscreteItem.setSkuBundleItem(skuBundleItem);
bundleOrderItem.getDiscreteOrderItems().add(bundleDiscreteItem);
}
if (saveItem) {
bundleOrderItem = (BundleOrderItem) saveOrderItem(bundleOrderItem);
}
applyAdditionalOrderItemProperties(bundleOrderItem);
return bundleOrderItem;
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class LegacyOrderServiceImpl method createDiscreteOrderItemRequest.
@Override
public DiscreteOrderItemRequest createDiscreteOrderItemRequest(Long orderId, Long skuId, Long productId, Long categoryId, Integer quantity) {
Sku sku = skuDao.readSkuById(skuId);
Product product;
if (productId != null) {
product = productDao.readProductById(productId);
} else {
product = null;
}
Category category;
if (categoryId != null) {
category = categoryDao.readCategoryById(categoryId);
} else {
category = null;
}
Order order = orderDao.readOrderById(orderId);
return createDiscreteOrderItemRequest(order, null, sku, product, category, quantity, null);
}
Aggregations