mage-os / module-newsletter-coupon

mage-os/module-newsletter-coupon

MageOS Newsletter Coupon Generator

  • Davide Lunardon
magento2-module Compatibility: 2.4.7-2.4.9 Code Quality: Fail Tests: N/A Security: Pass MIT

MageOS Newsletter Coupon Generator Module for Magento

Add automatically generated coupon management for newsletter subscribers


Overview

The Newsletter Coupon module allows you to generate a unique coupon for each newsletter subscriber. The coupon will be sent to the subscriber’s email after the subscription.

Features

This module add features to newsletter subscription module

  • generate a coupon for each subscription (must be a "SPECIFIC" coupon type salesrule with "Use Auto Generation" enabled)
  • send coupon informations to the subscribed user (extending magento newsletter email template)
  • controls each coupon expiration. You can change default configuration at Store > Configuration > MageOS > Newsletter Coupon > Coupon Expiration Expression config path.
  • adds graft for integrations with email marketing platforms

Installation

  1. Install it into your Mage-OS/Magento 2 project with composer:

    composer require mage-os/module-newsletter-coupon
    
  2. Enable module

    bin/magento setup:upgrade
    

Configuration

This module comes with standard functionality disabled. You'll need to enable it from configurations on Store > Configuration > MageOS > Newsletter Coupon > Enable Coupon Generation and connect a valid salesrule.
You can set the expiration delay time expression you prefer (https://www.php.net/manual/en/datetime.formats.relative.php) on Store > Configuration > MageOS > Newsletter Coupon > Coupon Expiration Delay path.
This will allow you to generate and link coupon on each new user newsletter subscription.
So create a new SalesRule from your admin panel on Marketing > Promotions > Cart Price Rules calling it "Newsletter Subscription promo" or something like this.
Remember that this salesrule must have "SPECIFIC" coupon type and "Use Auto Generation" checkbox must be flagged. Expiration coupon control comes from the module for each coupon adding regular expression setted on each coupon creation date.
Set the other rule's settings as you like.
Set the new rule id on Store > Configuration > MageOS > Newsletter Coupon > Used Sales Rule.

Integrations

You can create, delete or update subscriber informations on external platforms with a new module linked with mageOS_NewsletterCoupon.
Requirements:

  • if you've installed a 3rd party module that send newsletter email remember to disable magento's from Store > Configuration > Customers > Newsletter > Subscription Options > Disable Newsletter * Sending config path.
  • extend MageOS\NewsletterCoupon\Model\AbstractNewsletterIntegration class on your module adding logic on methods.
  • inject your new Vendor_Module\Model\MyClassName with a di argument preference like this:
<type name="MageOS\NewsletterCoupon\Api\SubscriberInformationRepositoryInterface">
    <arguments>
        <argument name="marketingEmailIntergrations" xsi:type="array">
            <item name="your_integration_name" xsi:type="object">Vendor\Module\Model\MyClassName</item>
        </argument>
    </arguments>
</type>
  • That's all, your module is now able to talk with your favorite email marketing platform

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog
and this project adheres to Semantic Versioning.

1.0.0

Added

  • First Commit
Versions
Version Stability QA Status Compatibility Released
1.1.0 stable Fail Magento 2.4.7-2.4.9 Details 2026-05-19 04:31:42
1.0.0 stable Not tested Not yet tested Details 2025-05-20 06:50:32

Requires 2

Package Constraint
php ^8.1
magento/module-newsletter *

Compatibility

Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.

Compatibility matrix (Magento × PHP)
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 Pass Pass
2.4.8 Pass Pass
2.4.9 Pass Pass

Code Quality

Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge — a phpcs finding can't make a module incompatible.

Static analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

Static analysis results
Tool Status Findings Summary
PHPCS Warning 64 64 warnings (ruleset: Magento2) — 21 auto-fixable with phpcbf
PHPMD Warning 6 6 rule violations (UnusedFormalParameter:6)
Cpd Pass 0
Composer validate Info 1 valid; 1 advisory note (composer validate --strict)

PHPStan

Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases. Cell → details modal.

PHPStan results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 13 13
2.4.8 13 13
2.4.9 13 13

Tests

Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.

Unit tests

Unit tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Integration tests

Integration tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Security

Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.

Security results
Tool Status Findings Summary
Composer audit Pass 0
Malware scan Pass 0
License
MIT
Authors

More from mage-os

View vendor
Make it pay

Turn an existing module into recurring revenue.

If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.