schrammel-codes / magento2-salesrule
Adds duplicate functionality and mass actions to Cart Price Rules
Package info
github.com/schrammel-codes/magento2-salesrule
Type:magento2-module
pkg:composer/schrammel-codes/magento2-salesrule
Requires
- php: ^8.1
- magento/framework: *
- magento/module-sales-rule: *
This package is auto-updated.
Last update: 2026-04-17 15:18:08 UTC
README
Streamline your promotional rule management with powerful duplication and mass management features for Magento 2 Cart Price Rules.
What This Module Does
This module extends Magento 2's Cart Price Rules (promotional discounts) with convenient management features that save time and reduce errors when managing multiple similar promotions.
Key Features
1. Duplicate Cart Price Rules
Create copies of existing promotional rules with a single click. Perfect for:
- Creating seasonal variations of successful promotions
- Setting up similar rules for different customer segments
- Testing rule variations without risking the original configuration
2. Enhanced Grid
The Cart Price Rules grid gets three additional columns at a glance:
- Rule Type: The discount type (e.g. Fixed, Percent, Buy X Get Y)
- Discount Amount: The configured discount value
- Stop Rule Processing: Whether this rule stops further rules from applying
Each row also gains an inline Duplicate shortcut in its Actions column.
3. Mass Actions
Manage multiple rules at once:
- Mass Duplicate: Copy several rules simultaneously
- Mass Delete: Remove multiple outdated rules in one action
- Mass Status Change: Enable or disable multiple rules at once
How It Works
Smart Duplication
When you duplicate a rule, the module:
- ✅ Copies all rule conditions and actions
- ✅ Adds "(Copy)" suffix to the rule name (overridable via Custom Fields configuration — see below)
- ✅ Keeps original active/inactive status (configurable — can force enabled or disabled)
- ✅ Copies customer group associations (configurable)
- ✅ Copies website assignments (configurable)
- ✅ Copies store-specific labels (configurable)
- 🔄 Resets coupon code (always reset, cannot be overridden by configuration)
- 🔄 Resets usage counter to zero (always reset, cannot be overridden by configuration)
- 🔄 Clears start and end dates (always reset, cannot be overridden by configuration)
- 🔄 Generates a new rule ID automatically (always reset, cannot be overridden by configuration)
- 🔄 Resets custom fields configured via Stores > Configuration > SchrammelCodes > Sales Rule (configurable)
This ensures your duplicated rules are ready to customize without inheriting usage history or active date ranges.
Traceability
Duplicated rules display a read-only "Duplicated From" hint on their edit page, showing the ID of the original rule.
On Adobe Commerce installations with staging enabled, the module resolves the staging row_id back to the
human-readable rule_id of the original rule so the reference stays meaningful across staging versions.
Benefits for Store Administrators
Time Savings
Instead of manually recreating complex promotional rules with dozens of conditions, duplicate existing ones and adjust only what's needed. A task that might take 15-20 minutes now takes seconds.
Consistency
Duplicating rules ensures all settings, conditions, and actions are copied exactly, reducing human error when creating similar promotions.
Flexibility
Quickly test variations of successful promotions or create region-specific versions of global campaigns without starting from scratch.
Efficiency
Mass actions let you manage multiple rules at once - perfect for seasonal cleanup, enabling holiday promotions, or deactivating expired campaigns.
Usage Guide
Duplicate a Single Rule
- Navigate to Marketing > Promotions > Cart Price Rules
- Find the rule you want to duplicate
- Click Select in the Actions column
- Choose Duplicate
- The duplicated rule appears in the grid with "(Copy)" appended to its name
Duplicate from Rule Edit Page
- Open any Cart Price Rule for editing
- Click the Duplicate button (next to Save/Delete)
- You'll be redirected to the edit page of the newly created copy
- Customize the copy as needed and save
Mass Duplicate Multiple Rules
- In the Cart Price Rules grid, select checkboxes for rules you want to duplicate
- Open the Actions dropdown (top left of grid)
- Select Duplicate
- Click Submit
- All selected rules are duplicated at once
Mass Delete Rules
- Select rules to delete using checkboxes
- Choose Delete from the Actions dropdown
- Confirm the deletion
- Selected rules are permanently removed
Mass Status Change
- Select rules to enable or disable
- Choose Change Status from the Actions dropdown
- Select Enabled or Disabled
- Click Submit
- All selected rules are updated immediately
Installation
# Install via Composer composer require schrammel-codes/magento2-salesrule # Enable the module bin/magento module:enable SchrammelCodes_SalesRule # Run setup upgrade bin/magento setup:upgrade # Clear cache bin/magento cache:clean
Permissions
The module adds two ACL resources:
SchrammelCodes_SalesRule::quote_duplicate- Permission to duplicate cart price rulesSchrammelCodes_SalesRule::config- Permission to manage the module configuration
Grant these permissions to admin roles as needed.
Compatibility
- Magento 2.4.x (Open Source and Adobe Commerce)
- PHP 8.1+
Adobe Commerce note: When
Magento_SalesRuleStagingis enabled, staging version fields are automatically reset on duplication — no companion module required.
Duplication Configuration
All duplication behaviour is configurable via Stores > Configuration > SchrammelCodes > Sales Rule > Duplication Settings.
Relationship Copying
Control whether each type of association is carried over to the duplicate:
| Setting | Default | Description |
|---|---|---|
| Duplicate Active Status | Keep as is | Set the active/inactive status of duplicated rules: keep the original value, always disable, or always enable |
| Copy Website Associations | Yes | Copy which websites the rule is assigned to |
| Copy Customer Group Associations | Yes | Copy which customer groups the rule applies to |
| Copy Store Labels | Yes | Copy store-specific rule name translations |
Set any of these to No if you prefer the duplicate to start without those associations, requiring you to assign them explicitly.
Custom Fields to Reset
Some Magento installations add extra columns to the salesrule database table (for example, fields added by custom modules or third-party integrations). By default, these columns are copied verbatim when a rule is duplicated.
The Custom Fields to Reset on Duplication table lets you declare which columns should be reset instead:
| Column | Description |
|---|---|
| Field Name (DB Column) | The exact column name in the salesrule table |
| Reset Value (leave empty for "NULL") | The value to set on the duplicate. Leave empty to reset to NULL. |
Click Add Field to add a row, then Save Config.
Example
To reset a custom field called my_custom_field to NULL on every duplication:
| Field Name | Reset Value |
|---|---|
my_custom_field |
(empty) |
To reset it to a fixed placeholder value instead:
| Field Name | Reset Value |
|---|---|
my_custom_field |
PENDING |
Overriding the rule name suffix
By default, duplicated rules get " (Copy)" appended to their name. You can override this by adding name as a custom field reset:
| Field Name | Reset Value |
|---|---|
name |
(empty — sets name to NULL) |
name |
My Custom Suffix |
Note: The reset value replaces the entire name, not just the suffix. If you want a custom suffix you will need to set a static value; dynamic name construction is not supported.
Fields that are always reset
The following fields are unconditionally reset on every duplication and cannot be overridden by this configuration, even if you add them to the table above:
| Field | Always reset to |
|---|---|
rule_id |
(new auto-generated ID) |
from_date |
NULL |
to_date |
NULL |
coupon_code |
NULL |
times_used |
0 |
Adobe Commerce only: When
Magento_SalesRuleStagingis active, the fieldscreated_in,updated_in, anddeactivated_inare also unconditionally reset to their default staging version values.





