Child pages
  • Affiliate - Magento 2
Skip to end of metadata
Go to start of metadata


Firefox user notice:

Please use a different web browser to view this document.

Sorry for the inconvenience.

Affiliate for Magento 2

Magento 2 Affiliate provides store owners with a complete toolset for affiliate campaign arrangement. You can precisely set up link and/or coupon-based affiliate campaigns with individual product promotion recommendations, permitted affiliate groups, commission types and amounts, etc. Additionally, admins can flexibly manage affiliate groups and accounts, affiliate program signup requests, process campaign-related transactions, monitor stats per promotion type.

Compatibility: Magento Open Source 2.1.X - 2.3.X, Magento Commerce 2.1.X - 2.3.X

   Product Page

Thank you for choosing Aheadworks!

Installing Affiliate

Command Line Installation

1. Backup your web directory and store database

2. Download the Affiliate installation package

 3. Upload the contents of the Affiliate installation package to your store root directory

 4. In the SSH console of your server, navigate to your store root folder:

cd path_to_the_store_root_folder

run the following command:

php -f bin/magento module:enable Aheadworks_Affiliate


php -f bin/magento setup:upgrade


php -f bin/magento setup:static-content:deploy

5. Flush the store cache; log out from the backend and log in again


Make sure the installation is done from under the FTP administrator account. Otherwise, make sure to set 775 permissions to the store root directory after the extension is deployed.

Composer Installation

1. Log in to your customer account at and navigate to Account -> Composer access;

2. Configure your store to work with the Aheadworks composer repository:

Add the composer repository to composer.json by running:

composer config repositories.aheadworks composer in the Magento installation root.

Use the provided key pair as a login and pass. You can optionally save them to the global composer auth file.

 3. You can start using AW composer now.

 For extension names, navigate to Account -> Composer access.

 4. Open the root Magento directory on your server and send Composer the following command:

composer require <component-name>:<version>

Note: Use the previously copied component name and version.

 5. Make sure that Composer finished the installation without errors. Flush the store cache, log out and log into the backend again.


Set up cron


If you have already configured cron jobs for your Magento installation, then you can skip this step. Read the following instructions on setting cron job for your Magento store: Magento user guide.

Generally it would be enough to run in the SSH console of your server: 



And insert the following line:  


Don't forget to confirm saving request when exit.


Introducing Affiliate

With the Magento 2 Affiliate extension, you can run profitable affiliate campaigns based on the 'pay-per-sale' model. An affiliate receives commissions for every purchase within the promoted campaign, including those that are not directly promoted by them (via a link or/and coupon code) but belong to the same campaign. Just like an ordinary yet effective affiliate campaign on Amazon.

Moreover, the module introduces the following features:

  • Custom lists of product recommendations to promote within a particular campaign;
  • Individual commission rates and commission holding periods per affiliate group;
  • The possibility to reward individual affiliate groups with higher commission rates;
  • Separate performance reports for coupon/link promotions available for both affiliates and admins;
  • Manual and automatic (by custom schedule) payouts.

Extension Logic

In the backend, the module introduces separate grids for each key affiliate management aspect: campaigns, affiliate groups, accounts, signup requests, transactions, and payouts. On the configuration level, one needs to deal with the general signup, commission, payout, and email configuration parameters.

On the storefront, a user is provided with a designated tab from where they can join affiliate programs, view recommendations, get links, generate coupon codes, monitor balance history and transactions. The organization logic is the same - the data and options are split between separate tabs, which facilitates convenient management.

Backend Configuration

Extension Settings

Start configuring the extension by going to Stores > Configuration > AHEADWORKS EXTENSIONS > Affiliate.

Extension Settings - 1

The configuration page is divided into four sections. We will explore each one separately.

The 'Signup Settings' section is presented by two parameters:

  • Select Terms & Conditions CMS Page - defines the page on your web store with affiliate program terms & conditions.

After the installation, the module adds a separate CMS Terms & Conditions page with sample content.

  • Admin Approval Needed - defines whether you need to manually approve affiliate program signup requests. If left to No, all requests will be approved automatically.

The 'Commission Configuration' section has the following options:

  • Add Commission When The Order Item Obtains Status - defines the referred customer's order status upon which the affiliate will get a commission (pending until the commission holding period expires): Ordered, Invoiced, or Shipped;



Commissions are accrued upon reaching a particular order item status, not order status. This is particularly useful for the orders that include the items that require commission accrual and those that don't.

In case an invoice and shipping are created at the same time (therefore, the order item instantly receives the hardcoded 'Shipped' status bypassing the 'Invoiced' status), the commission is accrued upon reaching the predefined status or the 'Shipped' status.


  • Deduct Commission When The Order Item Obtains Status - the option sets automatic commission deduction (before the commission holding period expires) upon the selected order status: Canceled, Refunded, or Returned.

The 'Payout Configuration' section contains the following parameters:

  • Minimum Balance for a Payout - defines the minimum payout balance (in the base currency) upon reaching which the payout can be created (either manually or automatically);
  • Allow Payout Requests - if enabled, the affiliate can send payout requests by sending requests from their account. The appropriate button appears when their balance reached the defined minimum value. This way, the affiliate can create payouts from the storefront and the admin can then process the newly created payouts from the admin area;
  • Generate Payout by Schedule - defines if payouts should be generated once in a certain period. Provided that the affiliate's minimum balance reached the defined value, the payout with all the available commissions will be created automatically;

  • Payout Creation Period, Days - defines the frequency of payout regular generation;
  • Enable Admin Payout Reminders - defines whether you should be reminded of regular payout issuing.

Extension Settings - 2

Lastly, this is the 'Email Configuration' section with a set of email configuration parameters:

  • Admin Email - the email address for admin alerts. If left empty, admin alerts will be disabled;
  • Sender - the name of the default email sender;
  • New Signup Request Template - the email template for new affiliate program signup requests;
  • New Payout Template the email template for new affiliate program payouts;
  • Payout Reminder Template the email template for payout issue reminders;



For store views with separate payout reminders related to the same template, the same reminder will be sent to each email address specified.

  • Payout Complete Template - the email template for payout completion reminders;
  • Payout Cancellation Template - the email template for payout cancellation alerts;
  • Affiliate Rejection Template - the email template for affiliate program signup request rejections.

Managing Affiliate Campaigns

Let's proceed to affiliate campaign management by following Marketing > Affiliate by AheadWorks > Campaigns.

Campaigns Grid

The grid is designed for affiliate campaign management and monitoring. The data in the grid is split by the following columns:

  • ID - an ID of a campaign;
  • Name- the name of the campaign;
  • Allow Link Generation - shows whether promotion via links is allowed within the campaign;
  • Coupon - shows whether promotion via coupon codes is allowed within the campaign;
  • Commission - the commission amount provided by the campaign. Can be fixed (displayed in the website's base currency) or percent (as shown in the above picture);
  • Status - the status of the campaign;
  • Website - the website the campaign is assigned to;
  • Action - provides the 'Select' box with the following per-campaign options: Edit, Delete, Disable.

From the 'Action' box above the grid, you can delete, enable, or disable campaigns one by one or massively.

To create a new campaign, click at the top right of the page.

Let's explore the main campaign parameters on the example of the already created campaigns. For this purpose, we'll choose the 'Edit' option from the 'Select' box in the 'Action' column.

Campaign Parameters - 1

Campaign parameters are split into several sections. We'll explore them one by one.

In the 'General Information' section, you can specify campaign credentials and choose the required affiliate groups (individual groups or all groups).

In the 'Conditions' section, you can set campaign-specific conditions based on cart item and product attributes. Remember that the conditions you set will be applied per item, not to the whole shopping cart.

Campaign Parameters - 2

With the 'Link Configuration' parameter set, you can enable link generation for your campaign and define a link tracking gap - the referred customer cookie's lifetime period during which the affiliate will be able to get commissions from campaign-related purchases.

If you need to precisely set up the coupon-based promotion type, use the 'Coupon Configuration' section. To enable the coupon parameters, choose Specific coupon in the 'Coupon' box. After this, you will be able to define a coupon code template, uses per affiliate (how many times an end user can use the provided coupon code), discount type (percent or fixed), and discount amount.


When the '0' value is set for the 'Uses per Affiliate' option, the number of coupon usages is unlimited.

Once any of the affiliates have generated a coupon code for the first time within the campaign, a mirror rule is created automatically in the 'Cart Price' rules. Without this rule, the coupon code can't be applied.

In this mirror rule, the 'Uses per Affiliate' option is automatically set to unlimited for all customer groups.



It's not recommended changing the mirror rule's settings since the campaign-related coupons won't work the way they are configured in the affiliate marketing campaign.


If you delete the Affiliate module, all the previously created rules will not be erased. This means that all the related coupons will keep working. To avoid this, you need to delete rules manually.

If you delete a website, all the assigned affiliate campaigns will be deleted. However, the previously configured mirror shopping cart rules will remain, meaning that you will have to delete them manually.

With the 'Campaign Configuration' option set, you can define the commission type (percent or fixed) and amount (displayed in the format defined by the commission type).

Lastly, this is the 'Recommended Products' section where you can optionally pick products to be displayed as recommendations for promotion. The recommendation list can be further edited whenever required.


To share campaigns with the same conditions between multiple websites, use the 'Save & Duplicate' option in the 'Save' box at the top right of the page.

Signup Requests  

All signup requests can be monitored and managed from Marketing > Affiliate by AheadWorks > Signup Requests.

Signup Requests Grid

The data in the 'Signup Requests' grid is broken down by the following columns:  

  • ID - an ID of a request;
  • Customer Name- the name of the customer;
  • Customer Email - the email address from which the customer sent a signup request;
  • Website - the website to which the customer sent the request;
  • Signup Date - the affiliate's signup date;
  • Referral Website  - the primary traffic source from where the affiliate will promote the products within the campaign;
  • Status - the current request status: Pending, Approved, or Declined;
  • Action - the column contains the 'Select' box with the following options: View, Delete, Approve, and Decline.

You can perform the latter three operations massively from the 'Actions' box above the grid.

In case of signup request decline, you can optionally specify the reason in the designated field on the 'Signup Request' 'page.

Signup Request Page


Let's see how accounts can be monitored within the module by going to Marketing > Affiliate by AheadWorks > Accounts.

Accounts Grid

The 'Accounts' grid lists all the necessary information about affiliate accounts split by the following columns:

  • Affiliate Name - the name of an affiliate;
  • Affiliate Email - the email address of the affiliate;
  • Website - the website from where the affiliate performs promotion;

The affiliate account is valid on a particular website. If the affiliate wants to have an account on several websites, they need to create separate credentials for each one. Thus, they will have separate affiliate accounts with individual balances on each website that might have individual base currencies.


  • Affiliate Group - the affiliate's group;
  • Signup Approval Date - the date when the affiliate's signup request was approved;
  • Available Commissions - the total sum of the available commissions (the ones with the holding period already expired) plus admin transactions per affiliate;
  • Paid Commissions - the total amount of paid commissions. The amount is calculated based on the sum of completed payouts;
  • Status - the current status of the affiliate's account;
  • Action - the column contains the 'Select' box with the following options: Edit and View Signup Request.

From the 'Actions' box above the grid, you can activate/deactivate the selected account(s).

On the 'Edit Affiliate Account' page, you can view the key affiliate account info, the affiliate's signup request (on a separate page), edit the account's status and group.

Edit Affiliate Account Page

Affiliate Groups

To view all affiliate groups presented in your store, follow Marketing > Affiliate by AheadWorks > Affiliate Groups.

 Affiliate Groups Grid

The 'Affiliate Groups' grid lists the main data about affiliate groups in the following columns:

  • ID - an id of an affiliate group
  • Group Name - the name of the group;
  • Commission Type - the type of commission provided for the group (fixed or percent);
  • Commission Premium - the amount of the commission premium (if provided) for the group;
  • Commission Holding Period, day(s) - the duration of the commission holding period (in days) per group;
  • Action - the column contains the 'Select' box from where you can edit/delete the corresponding group.

With the 'Actions' box above the grid, you can massively delete the selected affiliate group(s).

To create a new affiliate group, click above the grid.

Let's explore the main affiliate group parameters.

Edit Affiliate Group Page

So, when creating/editing an affiliate group, you need to indicate the group's Name, Commission Type, Commission Premium, and Holding Period.

By setting individual commission amounts and holding periods per group, you can reward the best performing affiliate groups with higher commissions and shorter holding periods. This way, you will encourage them to keep actively participating in your campaign as well as prompt the less performing ones to share more. Note that you can change those values by increasing/decreasing them anytime.


To monitor the entire affiliate program transaction flow in your store, go to Marketing > Affiliate by AheadWorks > Transactions.

Transactions Grid

The data in the 'Transactions' grid is divided by the following columns:

  • ID - an ID of a transaction;
  • Affiliate Name - the name of the affiliate whom the transaction relates to;
  • Affiliate Email- the email address of the affiliate;
  • Type - the type of the transaction: Commission (transactions from each campaign purchase), Payout (transactions accrued to affiliate balances. The completed payouts can be exported to the XML/CSV file formats), and Admin changes (positive/negative transactions that you manually create);



Commissions are created upon the following event:

The order item with (a) product(s) sorted by any campaign conditions obtained the status defined on the configuration level.

All admin manual transactions relate to the 'Admin Changes' transaction type.

  • Website - the website from where transactions are performed;
  • Status - the status of the transaction: Complete, Pending, or Canceled;

Balance changes upon transaction status updates are indicated in the table below.

Balance Status Change

  • Amount - the amount of the transaction;
  • Creation Date - the transaction's creation date;
  • Holding Period Expiration Date - the date when a) the transaction changes the status from Pending to Complete; b) pending commissions in the affiliate account get decreased by the transaction amount, while the available commissions increase by it, respectively;
  • Comment - the admin comment to the transaction. For transactions of the 'Commission' type, the comment includes the order item(s) for which the commission should be accrued;

  • Action - the column with active links to the 'Edit Affiliate Account' page.

To create a new transaction, click above the grid. You will be redirected to the page where you need to select the required affiliate, specify the transaction amount (positive or negative), and add a comment.

Create Transaction Page

Transaction flow is arranged in the way illustrated in the picture below.

Transaction Flow



Adding commissions for bundle order items

For complex purchases with both parent and child items the logic is the following:

  • An item has a particular status if either a parent item or all child items have this status;
  • To indicate which item type - parent or child - determines the end item's status, you need to consider the following bundle product options: Dynamic Price (Yes/No) and Ship Bundle Items (Together/Separately);
  • According to the core Magento 2 logic, a configurable product is equal to a bundle product with the 'Dynamic Price' option set to No and the 'Ship Bundle Items' parameter set to Together. Simply put, hereinafter it is suggested that the configurable type is a particular case for bundle products;
  • For products with Dynamic Price = No and Ship Bundle Items = Together, all statuses are determined by the parent item;
  • For products with Dynamic Price = Yes and Ship Bundle Items = Separately, all statuses are determined by child items;
  • For products with Dynamic Price = No and Ship Bundle Items = Separatelyby child items, only the 'Shipped' status is determined;
  • For products with Dynamic Price = Yes and Ship Bundle Items = Together, all statuses are determined by child itemsand the 'Shipped' status is determined by the parent item
  • The module doesn't determine the order item status independently. Instead, it relies on the native Magento 2 logic.


To monitor money outflow in the context of affiliate payouts, go to Marketing > Affiliate by AheadWorks > Payouts.

Payouts Grid

The 'Payouts' grid contains the key payout info split by the following columns:

  • ID - an ID of a payout;
  • Affiliate Name - the name of the affiliate;
  • Affiliate Email - the email address of the affiliate;
  • Type- the type of the payout (manual or automatic);
  • Payment Type - the type of payment (PayPal or other);
  • Payment Info - the additional payment info. If the affiliate uses PayPal as the payment type, this field will indicate their PayPal email address. In the case of another payment type, the field will contain the corresponding info about the appropriate payment destination;
  • Payout Amount - the amount of the payout;
  • Currency - the base currency of the store;
  • Status  - the status of the payout: Pending, Processing, Canceled, or Complete;
  • Created At - the payout creation date;
  • Updated At - the payout's last update date;
  • Action - the column contains the 'Select' box from where you can go to the affiliate details page, process, complete, or cancel the corresponding payout.

With the 'Actions' box above the grid, you can massively change the status of the selected payouts to Processing, Compete, or Canceled.


With above the grid, you can export the payout info into the CSV/XML file formats to issue mass payouts to affiliates. More specifically, the workflow goes in the following way:

  1. Payouts are exported to CSV/XML;
  2. The admin manually edits the exported payouts in accordance with the required payment processor's standards;
  3. The edited payouts are imported into the required payment processors;

  4. The admin issues payouts massively.

Sales by Affiliate Link Report

To access the performance stats of link-based promotions, go to Reports > Affiliate by AheadWorks > Sales by Affiliate Link.

Sales by Affiliate Link Report

The 'Sales by Affiliate Link' grid contains the reporting data split by columns:

  • Affiliate Email - the email address of the affiliate;
  • Campaign - the related affiliate campaign;
  • Hits - the number of clicks on the link;
  • Orders - the number of orders within the campaign;
  • Buyers  -  the number of visitors who came via the affiliate link and made at least one purchase;
  • Commissions - the available commission amount;

  • Conversion - the number of visitors who came via the affiliate link and made at least one purchase to hits ratio.


The report collects info only about available commissions and only for the last three months.

Sales by Coupon Report

To view the performance stats of coupon-based promotions, go to Reports > Affiliate by AheadWorks > Sales by Coupon.

Sales by Coupon Report

The 'Sales by Coupon' grid contains the reporting data split by columns:

  • Affiliate Email - the email address of the affiliate;
  • Campaign the related affiliate campaign;
  • Coupon Code - the coupon code of the affiliate;
  • Total № of Uses - shows how many times the coupon was used;
  • Commissions - the available commission amount.

The report collects info only about available commissions and only for the last three months.


Although in this release both the admin area and affiliate account encompass the affiliate campaign info only for the last three months, all statistics are stored in the 'aw_aff_link_statistics' table. If required, you can upload the data from the table to analyze it outside Magento.


Affiliate Account 

The module adds the 'Affiliate Program' section to a customer account from where one can send affiliate program signup requests, get links, generate coupon codes, monitor campaign stats per promotion type, and more! For user convenience, the information in the section is divided by the following tabs:

  • Information - contains the main info about the program, including the affiliate's referral link (the primary traffic source), payment type (PayPal or other), and payment information. The data in the tab can be edited anytime;
    Information Tab


  • Promotions - lists all the campaigns available to a particular affiliate with commission and premium (if available) amounts. From there, link/coupon generation takes place;

    Promotions Tab

The commission value is pulled from the campaign commission value. If the affiliate is a member of an affiliate group where the premium is more than 0, the green 'VIP' label will be displayed next to the regular commission amount.



Link processing goes by the following scenario:

  • The campaign and affiliate account data is extracted from a promo link;
  • The system verifies if the current affiliate account is allowed to participate in the campaign and if the campaign complies with the current website;
  • If validation expires, the appropriate cookie will be assigned to the visitor, the lifetime value will be taken from the campaign. In case of several cookies, the originally assigned cookie will not be overridden by the following ones as along until it becomes invalid or its lifetime.



Currently, coupon-based discounts are calculated including taxes. For example, we have a Subtotal = $20 and Tax Amount = $4. The native Magento rule determines the product price discount by coupon = 50%.

The Discount Amount is calculated by the following formula: (Subtotal ($20) + Tax Amount ($4)) * price discount (50%). Thus, the Discount Amount = $12.

The transaction amount is now calculated by the following formula: (Subtotal ($20) - Discount Amount (inc. Tax Amount ($12))* commission percent (50%) = $4.

  • Recommendations - displays all product recommendations per campaign;

    Recommendations Tab
  • Reports- presents the campaign performance stats separately for the coupon- and link-based promotions;

Reports Tab

  • Balance - indicates the balance info with already calculated totals to know when pending commissions become available;

    Balance Tab
  • Transactions - stores the history of the 'Completed' and 'Admin Changes' transaction types;

    Transactions Tab
  • Payouts - there, the affiliate can view their payout progress and send payout requests.

    Payouts Tab

To explore the affiliate program registration process in more detail, view our demonstration store.

Uninstalling Affiliate

Manual Removal

1. Disable the module by executing the following commands:

php bin/magento module:disable Aheadworks_Affiliate
php bin/magento setup:upgrade

2. Remove the extension files from the following folder:


Automatic Removal (via Composer)

1. Disable the module by executing the following commands:

php bin/magento module:uninstall Aheadworks_Affiliate

Product Page

Need Customization?

Magento 2 Custom Development Services by Aheadworks


You can always find the latest version of the software, full documentation, demos, screenshots, and reviews on

License agreement:
Contact Us:
Copyright © 2019 Aheadworks Co.

  • No labels