use of org.broadleafcommerce.core.catalog.domain.Product in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafRatingsController method viewReviewForm.
public String viewReviewForm(HttpServletRequest request, Model model, ReviewForm form, String itemId) {
Product product = catalogService.findProductById(Long.valueOf(itemId));
form.setProduct(product);
ReviewDetail reviewDetail = ratingService.readReviewByCustomerAndItem(CustomerState.getCustomer(), itemId);
if (reviewDetail != null) {
form.setReviewText(reviewDetail.getReviewText());
form.setRating(reviewDetail.getRatingDetail().getRating());
}
model.addAttribute("reviewForm", form);
return getFormView();
}
use of org.broadleafcommerce.core.catalog.domain.Product 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.Product 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);
}
use of org.broadleafcommerce.core.catalog.domain.Product in project BroadleafCommerce by BroadleafCommerce.
the class CatalogRelativeHrefProcessor method buildRelativeHref.
protected String buildRelativeHref(String tagName, Map<String, String> tagAttributes, String attributeName, String attributeValue, BroadleafTemplateContext context) {
Object result = context.parseExpression(attributeValue);
HttpServletRequest request = BroadleafRequestContext.getBroadleafRequestContext().getRequest();
String currentUrl = request.getRequestURI();
if (request.getQueryString() != null) {
currentUrl = currentUrl + "?" + request.getQueryString();
}
if (result instanceof Product) {
return catalogURLService.buildRelativeProductURL(currentUrl, (Product) result);
} else if (result instanceof Category) {
return catalogURLService.buildRelativeCategoryURL(currentUrl, (Category) result);
}
return "";
}
use of org.broadleafcommerce.core.catalog.domain.Product in project BroadleafCommerce by BroadleafCommerce.
the class ProductOptionsProcessor method populateModelVariables.
@Override
public Map<String, Object> populateModelVariables(String tagName, Map<String, String> tagAttributes, BroadleafTemplateContext context) {
Long productId = (Long) context.parseExpression(tagAttributes.get("productId"));
Product product = catalogService.findProductById(productId);
Map<String, Object> newModelVars = new HashMap<>();
if (product != null) {
addAllProductOptionsToModel(newModelVars, product);
addProductOptionPricingToModel(newModelVars, product, context, tagAttributes);
}
return newModelVars;
}
Aggregations