Commerce Bulk
Provides bulk operations and a service for bulk creation of Drupal Commerce entities such as product variations, attribute values, and taxonomy terms.
commerce_bulk
Overview
Commerce Bulk is a powerful Drupal Commerce module that enables store administrators to efficiently manage large numbers of product variations, attribute values, and taxonomy terms through bulk operations. The module provides a comprehensive set of VBO (Views Bulk Operations) actions that allow users to perform batch modifications on selected entities without tedious one-by-one editing.
At its core, the module includes the BulkVariationsCreator service which programmatically generates all possible product variation combinations based on configured attributes. This service is particularly useful for stores with products that have multiple attributes (like size, color, material), where manually creating each combination would be impractical.
The module also enhances the SKU field with a custom widget that supports automatic unique SKU generation with configurable prefixes, suffixes, and entropy settings. Additionally, it provides order anonymization functionality useful for GDPR compliance and data protection requirements.
Features
- Bulk creation of all possible product variation combinations based on attribute combinations
- Automatic SKU generation using PHP's uniqid() function with configurable prefix, suffix, and entropy settings
- Bulk variation actions: duplicate, delete, set price, adjust price, change SKU, change status, change title, move to top
- Bulk attribute value actions: change or add names, move to top, delete attribute values
- Bulk taxonomy term actions: duplicate/reorder/rename terms, delete terms
- Order anonymization action for GDPR compliance with configurable field selection and order age filtering
- Custom SKU field widget with options to hide field, set custom labels, and control maximum bulk creation limits
- Pass to hook action allowing custom module integration via hook_commerce_bulk_variation_alter()
- Views-based admin interface displaying variation statistics (total possible, created, not used, duplicates)
- Commerce Generate submodule for generating dummy products with Drush command support
Use Cases
Bulk create all product variations
When you have a product with multiple attributes (e.g., T-shirt with Size: S/M/L/XL and Color: Red/Blue/Green), use the 'Duplicate variation' action to automatically create all 12 possible combinations. Select one variation, choose the action, optionally narrow down attribute options, and submit. The module calculates all unused combinations and creates them with auto-generated SKUs.
Mass price adjustment for seasonal sales
To apply a 20% discount across multiple products, navigate to the variations tab, select all variations needing adjustment, choose 'Adjust price' action, select 'Subtract', enter '20', choose 'Percentage', and submit. This efficiently updates pricing across hundreds of variations.
GDPR-compliant order anonymization
To anonymize old customer data for GDPR compliance, go to the Orders page, select orders to anonymize, choose 'Anonymize Orders' action, select fields to anonymize (ip_address, billing_profile, shipping_profile, mail, data), optionally set order age filter, and submit. Can also be automated via cron using the provided example code.
Generate test products for development
Enable the Commerce Generate submodule, then use the UI at /admin/config/development/generate/products or Drush command 'drush gprod 100' to quickly populate your store with realistic test products including variations, prices, and images for development and testing.
Custom SKU pattern implementation
Implement hook_bulk_creator_sku_alter() in your custom module to generate SKUs following your business logic (e.g., including product type code, sequential numbers, or attribute codes) when using the bulk duplicate variation feature.
Tips
- Use the statistics display on the variations tab to track how many variations exist versus total possible combinations
- Configure the SKU widget's 'Maximum' setting based on your server capacity - start with lower values for complex products
- The 'Pass to hook' action enables unlimited customization possibilities - implement hook_commerce_bulk_variation_alter() for custom batch processing
- Order anonymization can be automated via cron - see the example code in commerce_bulk.module
- When generating test products with Commerce Generate, use the --shuffle-variations option for more realistic random variation combinations
Technical Details
Admin Pages 4
/product/{product_id}/variations
View and manage all variations for a specific product with bulk operation support. Displays statistics showing maximum possible variations, currently created variations, and unused combinations. Warns about duplicated variation combinations.
/admin/commerce-bulk-attribute/{commerce_product_attribute}
Manage attribute values with bulk operations. Access by clicking the 'Bulk' operation button on the product attributes list page.
/admin/marketplace/vocabulary/{taxonomy_vocabulary}
Manage taxonomy terms with bulk operations. Access by clicking the 'Bulk' operation button on the taxonomy vocabulary list page.
/admin/commerce/config/product-variation-types/{type}/edit/form-display
Configure the Commerce Bulk SKU widget settings for automatic SKU generation when creating variations.
Hooks 4
hook_commerce_bulk_variation_alter
Allows modules to alter product variations during the 'Pass to hook' bulk action. Receives the selected variations and optional JSON/XML data passed from the action form.
hook_bulk_creator_sku_alter
Allows modules to alter the auto-generated SKU before saving a product variation. Useful for implementing custom SKU patterns.
hook_commerce_bulk_attribute_value_alter
Allows modules to alter attribute value fields during the 'Change or add names' bulk action.
hook_commerce_bulk_term_new_alter
Allows modules to alter taxonomy term fields during the 'Duplicate, reorder, rename' bulk action.
Drush Commands 1
drush generate-products [num]
Generate dummy commerce products. Aliases: genpr, gprod
Troubleshooting 4
Adjust the 'Maximum' setting in the SKU widget configuration to a lower number (e.g., 100). Create variations in multiple batches by pressing the 'Create N variations' button multiple times. You can also temporarily increase php.ini max_execution_time using the option on the duplicate action form.
The module displays warnings when duplicate attribute combinations exist. Review the duplications list shown on the variations tab and delete unnecessary duplicates using the 'Delete variations' action.
SKUs must be unique across the entire Drupal site and not exceed 60 characters. Adjust your SKU prefix/suffix settings to ensure uniqueness, or implement hook_bulk_creator_sku_alter() for custom generation logic.
Disable the 'Generate variation titles based on attribute values' option in the product variation type settings before using bulk title changes.
Security Notes 3
- Order anonymization permanently modifies customer data - always backup before bulk anonymization
- The 'Delete variations' and 'Delete terms' actions permanently remove data and cannot be undone
- Access to bulk operations requires appropriate Commerce and taxonomy administration permissions