Page 1 of 1

Pointers for creating product bundles

Posted: Fri Feb 17, 2012 4:59 am
by avinash
Hi,

I am currently looking to implement the Product Bundle feature in broad leaf, I have actually referred the following post http://broadleafcommerce.org/forum/viewtopic.php?f=11&t=371&p=1122&hilit=product+bundle#p1116 and my understanding about creating a product bundle form the following post is that:

Shop Side :

1 ) Create a new Product sub type (Basically thinking of extending ProductSkuImpl) where in we could add references to other products which are part of the bundle.
2) Extend the CartServiceImpl and override the addSkuToOrder method to check if the product being added is of type ProductBundle, if so create a BundleOrderItemRequest and use it to create BundleOrderItem.

3) Add the BundleOrderItem to the current order.

Admin Side :

1) Customize the admin to enable user to add other products to the product of type ProductBundle.

is the above mentioned procedure correct or do I need to perform any other stuff to get this done.

Regards,
Avinash

Re: Pointers for creating product bundles

Posted: Tue Feb 21, 2012 11:01 am
by jefffischer
We already have domain, dao, service and admin support for the concept of product bundles. Take a look at the addBundleItemToOrder method on org.broadleafcommerce.core.order.service.OrderService.

Re: Pointers for creating product bundles

Posted: Wed Feb 22, 2012 3:30 am
by avinash
Hi Jeff,

Thanks for the response on that, yes I have seen the support for handling BundleOrderItem in the Cart and I am using the same for handling BundleProduct.

But I have few questions concerning this, currently my approach is that I have basically created a sub type BundleProduct for ProductSku. The BundleProduct has additional collection property bundleProductReferences of type BundleProductReference (OneToMany relationship). Each instance of type BundleProductReference holds a reference/pointer to the original product which is part of the bundle (This is similar to the approach being used for CrossSale and UpSale products).

I have basically customized the Admin panel to enable the admin to create product of type BundleProduct and add BundleProductReference to it (please refer to the attachments).

When ever a user adds a product of type BundleProduct I am creating an BundleOrderItemRequest and BundleOrderItem using the methods in the OrderService that you have pointed out above.

Now my question is that

1) The DiscreteOrderItem instances being created for each sku being added to the cart has a backward reference the SKu, and Product for which it has been created (getSku() and getProduct() methods in DiscreteOrderItem ). But for BundleOrderItem there is no property of sku, and product which refers back to the original BundleProduct for which it has been created. And also the BundleOrderItem is getting the sale and retail price by adding up the sale, retail prices of discrete order items instead of getting the price being assigned to the BundleProduct sku?

2) In the admin panel when I am creating a product of type Base Product or One to One product I am still able to see the Panel for adding "Bundle Product References" (which is some thing specific to BundleProduct type and not to One to One Product type or Base Product type) and I am able to add the Bundle Product References to them (This is not the case for simple properties like Zip code, sku prices, etc... which are being shown dynamically depending on the type of product being selected). Is there a way I could hide the functionality or block the user from doing so.

Thanks
Avinash

Re: Pointers for creating product bundles

Posted: Wed Feb 22, 2012 5:56 pm
by jefffischer
1) First of all, the Broadleaf BundleOrderItem is a different concept than what you're trying to do. BundleOrderItem, in Broadleaf, is simply a collection of DiscreteOrderItems in the cart. This is why it's totaling up the values from it's member DiscreteOrderItems. Since you are creating a Bundle product, then you should add the bundle product to the cart as a DiscreteOrderItem, since your product is taking care (presumably) of providing its retail/sale prices for the sum of its constituents. This retail/sale price should flow through naturally into the DiscreteOrderItem, and subsequently, the cart.

I assume you're doing this because you would like to give merchandisers control over the creation of a "bundle" concept.

2) Limiting visibility for association grids based on type is already something the admin supports. Take this example:

Code: Select all

getPresenterSequenceSetupManager().addOrReplaceItem(new PresenterSetupItem("fulfillmentGroupAdjustmentDS", new FulfillmentGroupAdjustmentListDataSourceFactory(), new AsyncCallbackAdapter() {
         public void onSetupSuccess(DataSource result) {
            fulfillmentGroupAdjustmentPresenter = new CreateBasedListStructurePresenter(getDisplay().getFulfillmentGroupAdjustmentDisplay(), new String[] {EntityImplementations.FULFILLMENT_GROUP}, BLCMain.getMessageManager().getString("newFGAdjustmentTitle"));
            fulfillmentGroupAdjustmentPresenter.setDataSource((ListGridDataSource) result, new String[]{"reason", "value", "offer.type"}, new Boolean[]{false, false, false});
            fulfillmentGroupAdjustmentPresenter.setReadOnly(true);
         }
      }));


When the CreateBasedListStructurePresenter constructor is called, one of the parameters is an array of types the grid is available to. In your case, you'll just need to make sure you specify your more derived type. This should cause the grid to only appear when the user clicks on the desired polymorphic type in the regular grid on the left.

Re: Pointers for creating product bundles

Posted: Thu Feb 23, 2012 1:54 am
by avinash
Thanks Jeff,

Now I get it, I should be treat my bundle product as any other product by simply creating DiscreteOrderItem for it when added to the cart.

But can you please clarify in which scenario should we be actually using BundleOrderItem?

Regards,
Avinash

Re: Pointers for creating product bundles

Posted: Mon Feb 27, 2012 12:19 pm
by jefffischer
BundleOrderItem is only useful when you want to have several order items in your cart, but you only want to display them to your customer as a single item. The caveats are:

1) The bundle order item does not have its own explicit pricing, it simply sums up its constituents
2) BundleOrderItem is a cart-time concept. It is not something that a merchandiser can generally control from the admin

If you need to allow explicit pricing for your "bundle", then I think the approach you are taking is best.

Re: Pointers for creating product bundles

Posted: Tue Feb 28, 2012 2:01 am
by avinash
Thanks, Jeff

I guess I am pretty clear about this now.