Drupal Commerce Blog

What's happening in the world of Drupal Commerce.

Improving the Experience of Commerce Bundles

Commerce Bundles, while very powerful, isn’t exactly the most user-friendly from a UI standpoint. However, it is very customizable and there are a few things we can do really easily to improve the overall experience:

Using a View for the Bundle Item Autocomplete

Out of the box, Commerce Bundle’s Bundle Item Autocomplete looks solely at the title. This doesn’t scale really well if you give all of your products in a set (e.g. S-XXL shirts) the same name, which is pretty common. So instead, we can modify the widget to use a custom view to load and search for autocomplete suggestions. To enable:

  1. Grab the view export @ Github and import it (admin/structure/views/import).
  2. Head over to Administration → Store Settings → Bundle Item Types (admin/commerce/config/bundle-items).
  3. Click on manage fields (admin/commerce/config/bundle-items/bundle-item/fields).
  4. Edit the widget the product field and then click Field settings.
  5. Change the Mode to “Views: Filter by an entity reference view”.
  6. Under Views used to select the entities, chose the view you imported in step 1.
  7. Enjoy!

Old results on the left, using the view on the right.

Automating Bundle Group Creation

If you have many bundles you want to create, you can automate the process of creating the groups using Rules and Views Bulk Operations. Here is a brief overview of how it works.

An overview of how bundle creation works in rules.

The “Create Bundle form a Product Display” creates the bundle group. In it, there is a loop which creates a bundle item for each product reference that exists in the node that was passed into the rule. The “Create Budnle Item from Product” rule creates the Bundle Item entity and returns the new item’s ID back to the calling rule so that it can add it to the entity reference of the bundle group. Finally, the “Copy into Bundle” rule exists so that View Bulk Operations can make the action available to end users.

  1. Grab a copy of the export Rules and import the rules.
  2. Customize to your liking.
  3. Enable in VBO.

To enable in Commmerce Kickstart, or if you are using the Commerce Backoffice Products, edit the “Commerce Backoffice: Products (Content)” (admin/structure/views/view/commerce_backoffice_products/edit) view and click on the “Bulk operations: Content” field link. Under “Selected bulk operations” check the “Copy into Bundle” checkbox. Save and enjoy.

Click on the Bulk Operations field and ensure the "Copy Into Bundle" is checked under Selected Bulk Operations

If you aren’t using the above modules, then you will have to create a view that shows content, add the “Bulk operations: Content” field, and set it up manually. The view will need to show Content, and not products since it operations on nodes and not the individual products.

Hope these tips are helpful! Please share any feedback in the comments, and put suggestions for Commerce Bundle into the Commerce Bundle Issue Queue.

Tags: 
Nicholas Vahalik
Posted: Apr 24, 2014

Comments

Maaz Siddiqui on June 13, 2014

First of all thanks a lot for this great module, this blog and a video on youtube to demonstrate the usage of this module. However, I had some problems while following this blog. Maybe I am being a bit silly, but please help me out to clear my understanding of this blog.

The problems are :

1,) In the section where you asked to import the view, in point no. 4 you said to "Edit the widget the product field and then click Field settings.". I just didn't understood this point. What edit/change should we do to "product field's widget".

2.) The rules 1 and 3, i.e; [copy_product_to_bundle.json] and [vbo_action_create_bundle.json] are not getting imported. On trying to import rule 1 I am getting the following error :

Integrity check for the imported configuration failed. Error message: Missing configuration for parameter <em class="placeholder">param_commerce_stock</em>..

And on trying to import rule 3 I am getting the following error :

Integrity check for the imported configuration failed. Error message: Unknown action <em class="placeholder">component_rules_copy_product_to_a_bunde</em>..

Please help me out as soon as possible. Thanks you.