cancel
Showing results for 
Search instead for 
Did you mean: 

Bulk add to cart

Former Member
0 Kudos

Is there any way I could bulk upload the products into the cart within a batch? The addToCart(...) method of CommerceCartService adds one product at a time.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

There is something in the B2B accelerator that might help you:

/hybris/bin/ext-accelerator/b2bacceleratorfacades/src/de/hybris/platform/b2bacceleratorfacades/order/impl/DefaultB2BCartFacade.java

it implements the method:

 public List<CartModificationData> addOrderEntryList(final List<OrderEntryData> cartEntries)

Used by

/hybris_b2c/bin/ext-template/yb2bacceleratorstorefront/web/src/de/hybris/platform/yb2bacceleratorstorefront/controllers/misc/AddToCartController.java

    @RequestMapping(value = "/cart/addGrid", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
     public final String addGridToCart(@RequestBody final AddToCartOrderForm form, final Model model) {
         List<OrderEntryData> orderEntries = getOrderEntryData(form.getCartEntries());
         final List<CartModificationData> modifications = cartFacade.addOrderEntryList(orderEntries);
 
         model.addAttribute("modifications", modifications);
         model.addAttribute("numberShowing", Config.getInt(SHOWN_PRODUCT_COUNT, 3));
 
         for(CartModificationData modification : modifications)
         {
             addStatusMessages(model, modification);
         }
 
         return ControllerConstants.Views.Fragments.Cart.AddToCartPopup;
     }

The data is posted there by the view:

/hybris/bin/ext-template/yb2bacceleratorstorefront/web/webroot/WEB-INF/views/desktop/pages/product/productOrderFormPage.jsp