PHPackages                             schrammel-codes/magento2-salesrule-commerce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. schrammel-codes/magento2-salesrule-commerce

ActiveMagento2-module

schrammel-codes/magento2-salesrule-commerce
===========================================

Commerce staging support for SalesRule duplicate functionality

1.0.3(3mo ago)0567↓50%1MITPHPPHP ~8.1.0||~8.2.0||~8.3.0

Since Jan 26Pushed 3mo agoCompare

[ Source](https://github.com/schrammel-codes/magento2-salesrule-commerce)[ Packagist](https://packagist.org/packages/schrammel-codes/magento2-salesrule-commerce)[ RSS](/packages/schrammel-codes-magento2-salesrule-commerce/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (8)Used By (0)

SchrammelCodes\_SalesRule
=========================

[](#schrammelcodes_salesrule)

Adobe Commerce add-on for the `SchrammelCodes\_SalesRule` module, ensuring proper handling of Content Staging &amp; Preview when duplicating Cart Price Rules.

 [![Supported Magento Versions](https://camo.githubusercontent.com/2113b3a30955562f026a2b7dda3a09fee30d0c49aacbfce67193c5dc7b434617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d6167656e746f2d322e342d627269676874677265656e2e7376673f6c6f676f3d6d6167656e746f266c6f6e6743616368653d74727565267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/2113b3a30955562f026a2b7dda3a09fee30d0c49aacbfce67193c5dc7b434617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d6167656e746f2d322e342d627269676874677265656e2e7376673f6c6f676f3d6d6167656e746f266c6f6e6743616368653d74727565267374796c653d666c61742d737175617265) [![Latest Stable Version](https://camo.githubusercontent.com/3b516328205ee5622565d7301edb4cafb13fb330387b728241743c8974ce2775/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73636872616d6d656c2d636f6465732f6d6167656e746f322d73616c657372756c652d636f6d6d657263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schrammel-codes/magento2-salesrule-commerce) [![Composer Downloads](https://camo.githubusercontent.com/0de6770a304c6e203039a9721071469ef57a445b81b3a68621ce3bd442c073f8/68747470733a2f2f706f7365722e707567782e6f72672f73636872616d6d656c2d636f6465732f6d6167656e746f322d73616c657372756c652d636f6d6d657263652f646f776e6c6f616473)](https://packagist.org/packages/schrammel-codes/magento2-salesrule-commerce) [![Maintained - Yes](https://camo.githubusercontent.com/04aba48520e6322ebc6c41b7995626a88ce408bd46ec4eb15ae474936b345276/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61696e7461696e65642533462d7965732d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/schrammel-codes/magento2-salesrule-commerce/graphs/commit-activity) [![License - MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://opensource.org/licenses/MIT)

What This Module Does
---------------------

[](#what-this-module-does)

This is a companion module for [`SchrammelCodes_SalesRule`](https://github.com/schrammel-codes/magento2-salesrule) specifically designed for Adobe Commerce Edition.
It ensures that when you duplicate Cart Price Rules, the Commerce-specific Staging &amp; Preview features work correctly.

### Why You Need This Module

[](#why-you-need-this-module)

Adobe Commerce Edition includes advanced Staging &amp; Preview features that allow scheduling content and promotional changes for future dates. These features use special database fields that need proper handling during duplication.

**Without this module:**

- Duplicated rules might inherit incorrect staging metadata
- Rules could appear in unexpected staging campaigns
- Database conflicts could occur

**With this module:**

- ✅ Duplicated rules are always created as new permanent rules
- ✅ Staging fields are properly reset to default values
- ✅ Duplicated rules are independent and ready for their own staging campaigns
- ✅ Store labels are preserved correctly

How It Works
------------

[](#how-it-works)

### Automatic Staging Field Management

[](#automatic-staging-field-management)

When you duplicate a Cart Price Rule using the `SchrammelCodes_SalesRule` module, this Commerce extension automatically:

1. **Resets the Version Range**

    - Sets `created_in` to `1` (main permanent version)
    - Sets `updated_in` to `2147483647` (maximum version, meaning "forever")
    - This makes the duplicated rule a permanent rule, not tied to any staging campaign
2. **Clears the Row ID**

    - Removes the staging row ID so Magento generates a new one
    - Ensures the duplicated rule is truly independent in the database
3. **Preserves Store Labels**

    - Re-saves store-specific labels with the correct new row ID
    - Maintains your multi-store rule naming without manual re-entry

### What This Means for You

[](#what-this-means-for-you)

**Scenario**: You have a "Black Friday 2025" promotion scheduled as a staging campaign. You want to duplicate it as the basis for "Cyber Monday 2025".

**Result**:

- The duplicated rule is created as a fresh, permanent rule
- It's not connected to the Black Friday staging campaign
- You can schedule it for Cyber Monday as a new staging campaign
- All store labels are preserved correctly

Installation
------------

[](#installation)

### Prerequisites

[](#prerequisites)

This module **requires**:

1. **Adobe Commerce Edition** (not for Open Source)
2. **`SchrammelCodes_SalesRule`** module installed and enabled
3. **`Magento_SalesRuleStaging`** (included with Magento Commerce)

### Installation Steps

[](#installation-steps)

```
# Enable both modules
bin/magento module:enable SchrammelCodes_SalesRule SchrammelCodes_SalesRuleCommerce

# Run setup upgrade
bin/magento setup:upgrade

# Clear cache
bin/magento cache:clean
```

Usage
-----

[](#usage)

This module works automatically in the background. Once installed, simply use the duplicate features from the `SchrammelCodes_SalesRule` module as normal:

- Duplicate from grid actions
- Duplicate from rule edit page
- Mass duplicate multiple rules

The Commerce extension ensures all staging fields are handled correctly without any additional steps from you.

Technical Details
-----------------

[](#technical-details)

### Architecture

[](#architecture)

- **Plugin-Based**: Uses an `afterDuplicate` plugin to extend the base duplication logic
- **Non-Intrusive**: Doesn't modify core Magento code or the base SalesRule module
- **Error-Safe**: Includes comprehensive error handling and logging

### Staging Field Values

[](#staging-field-values)

The module sets these specific values for Commerce staging:

FieldValueMeaning`created_in``1`Main timeline version`updated_in``2147483647`Maximum version (permanent)`row_id``null` → auto-generatedNew unique row identifierThese values ensure the duplicated rule:

- Exists on the main timeline (not in a staging campaign)
- Has no end date in the staging system
- Gets a fresh database identifier

### Error Handling

[](#error-handling)

If staging modifications fail (database errors, permission issues, etc.):

- The duplication still succeeds with the base rule data
- Errors are logged for administrator review
- Users see the duplicated rule (though staging fields might need manual verification)

Compatibility
-------------

[](#compatibility)

- **Adobe Commerce Edition 2.4.x**
- **PHP 8.1, 8.2, 8.3**
- **Requires `SchrammelCodes_SalesRule` 1.0.0+**

**Not compatible with Magento Open Source** (which doesn't include Staging features).

Benefits for Commerce Users
---------------------------

[](#benefits-for-commerce-users)

### Workflow Efficiency

[](#workflow-efficiency)

Duplicate rules from past staging campaigns and schedule them as new future campaigns without manual field adjustments.

### Data Integrity

[](#data-integrity)

Automatic handling of complex staging database relationships prevents orphaned records and database inconsistencies.

### Peace of Mind

[](#peace-of-mind)

Comprehensive unit testing and error handling ensure reliable operation even in edge cases.

### Multi-Store Support

[](#multi-store-support)

Store-specific labels are automatically preserved and correctly linked to the new rule version.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance82

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

4

Last Release

96d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e54f6b54d30204518e69b61769d11fee324a30a0e48446d300e92ab4628bb0e9?d=identicon)[aschrammel](/maintainers/aschrammel)

---

Top Contributors

[![aschrammel](https://avatars.githubusercontent.com/u/1203434?v=4)](https://github.com/aschrammel "aschrammel (10 commits)")

### Embed Badge

![Health badge](/badges/schrammel-codes-magento2-salesrule-commerce/health.svg)

```
[![Health](https://phpackages.com/badges/schrammel-codes-magento2-salesrule-commerce/health.svg)](https://phpackages.com/packages/schrammel-codes-magento2-salesrule-commerce)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
