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
概要
Commerce Bulkは、ストア管理者が一括操作を通じて大量の商品バリエーション、属性値、タクソノミータームを効率的に管理できるようにする強力なDrupal Commerceモジュールです。このモジュールは、選択したエンティティに対して、面倒な1件ずつの編集なしにバッチ処理で変更を行えるVBO(Views Bulk Operations)アクションの包括的なセットを提供します。
モジュールの中核には、設定された属性に基づいてすべての可能な商品バリエーションの組み合わせをプログラムで生成するBulkVariationsCreatorサービスが含まれています。このサービスは、複数の属性(サイズ、色、素材など)を持つ商品を扱うストアで特に有用であり、各組み合わせを手動で作成することが現実的でない場合に役立ちます。
また、このモジュールはSKUフィールドを拡張し、設定可能なプレフィックス、サフィックス、エントロピー設定による自動一意SKU生成をサポートするカスタムウィジェットを提供します。さらに、GDPRコンプライアンスやデータ保護要件に役立つ注文匿名化機能も提供しています。
Features
- 属性の組み合わせに基づくすべての可能な商品バリエーションの一括作成
- 設定可能なプレフィックス、サフィックス、エントロピー設定を使用したPHPのuniqid()関数による自動SKU生成
- バリエーション一括アクション:複製、削除、価格設定、価格調整、SKU変更、ステータス変更、タイトル変更、先頭へ移動
- 属性値一括アクション:名前の変更または追加、先頭へ移動、属性値の削除
- タクソノミーターム一括アクション:タームの複製/並び替え/名前変更、タームの削除
- 設定可能なフィールド選択と注文経過日数フィルタリングによるGDPRコンプライアンスのための注文匿名化アクション
- フィールドの非表示、カスタムラベル設定、一括作成最大数の制御オプションを持つカスタムSKUフィールドウィジェット
- hook_commerce_bulk_variation_alter()を介したカスタムモジュール統合を可能にするPass to hookアクション
- バリエーション統計(総可能数、作成済み、未使用、重複)を表示するViewsベースの管理インターフェース
- Drushコマンドサポートを備えたダミー商品生成用のCommerce Generateサブモジュール
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