Search in sources :

Example 41 with Category

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);
    }
}
Also used : BreadcrumbDTO(org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO) Category(org.broadleafcommerce.core.catalog.domain.Category)

Example 42 with Category

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;
}
Also used : BreadcrumbDTO(org.broadleafcommerce.common.breadcrumbs.dto.BreadcrumbDTO) Category(org.broadleafcommerce.core.catalog.domain.Category) ArrayList(java.util.ArrayList)

Example 43 with Category

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;
}
Also used : Category(org.broadleafcommerce.core.catalog.domain.Category)

Example 44 with 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;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) Category(org.broadleafcommerce.core.catalog.domain.Category) BundleOrderItem(org.broadleafcommerce.core.order.domain.BundleOrderItem) DiscreteOrderItemRequest(org.broadleafcommerce.core.order.service.call.DiscreteOrderItemRequest) SkuBundleItem(org.broadleafcommerce.core.catalog.domain.SkuBundleItem) ProductBundle(org.broadleafcommerce.core.catalog.domain.ProductBundle) Product(org.broadleafcommerce.core.catalog.domain.Product) Sku(org.broadleafcommerce.core.catalog.domain.Sku)

Example 45 with Category

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);
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Category(org.broadleafcommerce.core.catalog.domain.Category) Product(org.broadleafcommerce.core.catalog.domain.Product) Sku(org.broadleafcommerce.core.catalog.domain.Sku)

Aggregations

Category (org.broadleafcommerce.core.catalog.domain.Category)49 Product (org.broadleafcommerce.core.catalog.domain.Product)18 Sku (org.broadleafcommerce.core.catalog.domain.Sku)13 CategoryImpl (org.broadleafcommerce.core.catalog.domain.CategoryImpl)10 Order (org.broadleafcommerce.core.order.domain.Order)8 ExtensionResultStatusType (org.broadleafcommerce.common.extension.ExtensionResultStatusType)7 CategoryProductXref (org.broadleafcommerce.core.catalog.domain.CategoryProductXref)7 ProductImpl (org.broadleafcommerce.core.catalog.domain.ProductImpl)7 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)7 ArrayList (java.util.ArrayList)6 CategoryProductXrefImpl (org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl)6 CategoryXref (org.broadleafcommerce.core.catalog.domain.CategoryXref)6 Money (org.broadleafcommerce.common.money.Money)5 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)5 Customer (org.broadleafcommerce.profile.core.domain.Customer)5 ProductBundle (org.broadleafcommerce.core.catalog.domain.ProductBundle)4 BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)4 Calendar (java.util.Calendar)3 ServiceException (org.broadleafcommerce.common.exception.ServiceException)3 ExtensionResultHolder (org.broadleafcommerce.common.extension.ExtensionResultHolder)3