Product Bundles

Manual · Interfaces

Bundles work with other systems too.

Bundles are records of Shopware like products. They can be imported and exported as CSV, queried in rules, shown and put into the cart through the Store API. The calculations in the background run as scheduled tasks or through console commands.

In the administrationSettings › System › Import/Export and Settings › Automation › Rule Builder

Import and export

Four profiles for bundles, components and assignments

The plugin brings profiles of its own for the import and export of Shopware. So you create many bundles in a spreadsheet, match them with a warehouse system or back them up.

  1. 1Open Settings › System › Import/Export and the tab Export or Import.

  2. 2Choose one of the four profiles of the plugin under Profile.

  3. 3Start export creates the CSV file; for the import you upload it and start the import.

The profiles:

  • Bundles: the bundles themselves with kind, rebate, limits, period, sales channels, rule, display, texts and product numbers.

  • Bundle components: the products of every bundle with quantity, position, whether it can be left out and the range of its quantity.

  • Bundle assignments: which products show a bundle.

  • Bundle assignments to product groups: which dynamic product groups show a bundle.

An empty field selectable of a component stays empty in the file and is read as empty on import, not as 0. How to give one bundle to many products at once is shown in Bundles in bulk.

Rules and product groups

Three conditions in the Rule Builder ask about bundles.

In the group "Product bundles" of the conditions. With them you tailor shipping methods, payment methods, promotions or flows to carts with bundles.

  • Cart contains bundles: whether a bundle is in the cart.

  • Cart contains bundle (choice): whether at least one of the chosen bundles is in the cart, or none of them.

  • Line item is from bundle (choice): whether a line item belongs to one of the chosen bundles, for a promotion on certain bundles, for instance.

The line item conditions of Shopware, such as weight, category or tag, check the components of a bundle. A rule a bundle uses cannot be deleted as long as the bundle uses it.

Dynamic product groups show bundles but do not ask about them.

A bundle can be assigned to a dynamic product group; then every product of the group shows the bundle, also one that joins later. Which products are in the group, Shopware works out. Bundles and their assignments are no condition in the editor of the product groups (Assignment).

Store API, Admin API and script

Reading the bundles of a product and putting them into the cart

For headless shops, apps and own front ends. The Store API checks a bundle exactly like the form of the product page.

  • GET or POST /store-api/dvsn-bundle/product/{productId} returns the bundles of a product as its page shows them; empty when the plugin is off in the sales channel.

  • POST /store-api/dvsn-bundle/cart puts a bundle into the cart, with productId, bundleId, products, selection, quantity and quantities like the form.

  • The cart route of Shopware, POST /store-api/checkout/cart/line-item, takes a bundle too: type dvsn-bundle, referencedId the product of the page, quantity the number of bundles, the other details in the payload.

  • When the shop declines a bundle, it answers with 400 and the error DVSN_BUNDLE__NOT_ADDED with its notice.

  • The Admin API reaches bundles, components and assignments through their entities, such as dvsn_bundle.

  • The script of a bundle on the product page reports the events afterInit, afterRefresh and beforeSubmit; a theme hooks into them.

The flow trigger "Bundle ordered" is described in the chapter Orders.

Scheduled tasks and console commands

Three tasks run in the background, three commands do the same on demand.

Every call works for at most 55 seconds; what it does not finish, the next one goes on with. The buttons in the administration are not affected.

TaskInterval by defaultConsole command
Suggestions from orders (dvsn_bundle.order_suggestions)every 4 hoursdvsn:bundle:suggestions:orders
AI suggestions (dvsn_bundle.ai_suggestions)every 15 minutesdvsn:bundle:suggestions:ai
Clearing the AI log (dvsn_bundle.ai_log_cleanup)dailydvsn:bundle:ai-log-cleanup
You call the commands with bin/console, for instance from a cron job of your own.

Where to find them in the settings (Catalogues › Bundles › side menu System › Settings):

  • Card Scheduled tasks and console › Run the scheduled tasksOff: the three scheduled tasks return at once at every call and do nothing. A calculation under way waits until the tasks are on again and then continues where it stopped; a cron job of your own can call the console commands instead. The buttons in the administration are not affected.

  • Card Scheduled tasks and console › Allow the console commandsOff: every console command with the prefix "dvsn:bundle:" stops with a message before it does anything. The administration is not affected.

Common questions

Can I import bundles as CSV?

Yes, through the import/export of Shopware with the four profiles of the plugin: bundles, bundle components, bundle assignments and bundle assignments to product groups.

Is there an API for bundles?

Yes. The Store API returns the bundles of a product as its page shows them and puts a bundle into the cart, with the same checks as the product page. The Admin API reaches bundles through their entities.

Can I add a bundle through the cart route of Shopware?

Yes. POST /store-api/checkout/cart/line-item takes a bundle with the type dvsn-bundle, the product of the page as referencedId and the details of the bundle in the payload. When the shop declines it, it answers with 400 and DVSN_BUNDLE__NOT_ADDED.

Which rule conditions does the plugin bring?

Three in the group "Product bundles": "Cart contains bundles", "Cart contains bundle (choice)" and "Line item is from bundle (choice)". The line item conditions of Shopware also check the components of a bundle.

Can I start the calculation of the suggestions from a cron job?

Yes, with bin/console dvsn:bundle:suggestions:orders and dvsn:bundle:suggestions:ai, as long as "Allow the console commands" is on. With "Run the scheduled tasks" off such a cron job takes over the work of the tasks.

What do the switches for tasks and console do?

Off, the three tasks return at once on every call, a calculation that has begun waits and goes on later. Off, every command with the prefix dvsn:bundle: stops with a message. Both apply to the whole shop; they do not affect the buttons of the administration.