How to Import and Export Magento 2 Catalog Price Rules

- E-Commerce, Magento 2, Our extensions

Catalog Price Rules is a sales booster that allows running price-focused campaigns based on the discounts for products with particular attributes and their combinations. Being a native marketing tool, Catalog Price Rules are extremely user-friendly to set up. However, like any other separate entity, the functionality presents its specifics when it comes to importing. The details are carefully noted in the article below.

'

Overview

It is impossible to import catalog price rules via the native Magento 2 tool. The fact pushes merchants to look for alternative software with advanced data transfer options. Improved Import and Export provides all the necessary resources for performing fast and safe catalog price rule import. 

Whether you update your database, connect your Magento 2 store with another platform, or migrate to Magento 2, the comprehensive architecture of the extension will help you to implement data in various ways. 

Improved Import and Export offers the enhanced data transfer tool in comparison to the native functionality. Along with the support of an extensive list of Magento 2 entities, the extension enables:

  • Both manual and automatic transfers with cron;
  • Additional data file formats, including CSV, XML, and others;
  • New import sources — Dropbox, GoogleSheets, etc.;

To explore the features, visit the extension page.

Sample Table for Catalog Price Rule Import 

As Magento 2 requires an entity table to retrieve data from during import, the first step is to compose the relevant structure. The fastest way to get one is to visit the Master Google Sheet created by the FireBear team. Here you can explore a sample file with a detailed explanation of the processed attributes. The corresponding table contains all the necessary info to serve as a base for your catalog price rule import.

If you want to compile a new import table from scratch, mind the following requirements for attribute creation:

Character set Unicode (UTF-8)
Field separator Comma, Tab
Text delimiter

Catalog Price Rule Attributes

In this chapter, you can find the info on the catalog price rule attributes that must be included in an import table.

Attribute name Reference Values Value example
rule_id ID of the catalog price rule. It is a unique identifier that you can use to update a particular catalog price rule Numeral 25
name The name of the catalog price rule Can be any value Underwear 10% off
description Description of the catalog price rule Can be any value 10% discount on men’s underwear sponsored by Improved Import and Export
website_ids IDs of the websites the catalog price rule is enabled for Website ID value 1
customer_group_ids Customer Groups that will be able to use the discount Customer group IDs can be found at Customers > Custom Groups > ID column.

Multiple values must be separated by commas.

0,1,2,3
from_date The date from which the cart price rule becomes active The date is processed in the following format:

yyyy/dd/mm

For example:

If you want a discount to be active from the 27th of December 2019, the value should look like:

2019-12-27

2019-12-27
to_date The date to which the cart price rule becomes active The date format should follow:

yyyy/dd/mm

For example:

If you want the discount to stop being displayed on the 31st of December 2019, the value should look like:

2019-12-31

2019-12-31
conditions_serialized The complex syntax that defines active conditions and condition combination that trigger the rule Values for categories, SKU, and product attributes enclosed in JavaScript. 

Can contain letters, numerals, and punctuation marks.

See the Sample Table
stop_rules_processing The attribute corresponds to the “Discard subsequent rules” setting. If the option is enabled all other catalog price rules will not be applied for the product 0 – Discard subsequent rules disabled

1 – Discard subsequent rules enabled

1
simple_action The attribute corresponds to the “Actions > Apply” setting. Defines the type of discount applied by the rule by_percent – the discount amount is a percent of the product price

by_fixed – the discount amount is a fixed sum

to_percent – the product price is reduced to a percent of the regular price

to_fixed – the product price is reduced to a fixed amount

to_fixed
discount_amount The amount of the discount applied to the products by the catalog price rule Numeral 15
sort_order The rule application priority Numeral (where 1 defines the highest priority) 4
is_active Specified whether the catalog price rule is enabled or disabled 0 – is disabled

1 – is enabled

1

 

Configuration of Catalog Price Rule Import

Once you have completed the data table for a catalog price rule import and installed Improved Import and Export, you are fully equipped for running the procedure. Follow System > Improved Import/Export > Import Jobs to create a new import job.

Step 1: Configuring general settings and cron 

Start with specifying general info about the rule in the first section at the job setting page. In case you need to enable automatic job running, here you can also schedule cron updates.

Step 2: Selecting Import Entity

Next, you choose ‘Catalog Price Rules’ from the list of supported entities in the import settings. If you transfer data from another platform or Magento 1, check the ‘Platform’ option to simplify the import process with built-in presets.

Step 3: Defining Import Behavior 

You are able to add, update, replace, or delete data during the import. Decide which import behavior suits your import goals. Specify the separators right in the section if the default values do not satisfy you.

Step 4: Activating Import Source

Improved Import and Export can retrieve data from various sources. The extension’s distinctive feature is the support of REST and SOAP API, FTP and SFTP, Dropbox and Google Sheets, URL, and direct file upload. The data table can provide in CSV, XML, Json, XLSX, ODS, ZIP, and TAR formats, which allows you to select any type you work with and stay flexible with your import.

You can map attributes to make sure no data will be overlapped. After the configuration is finished, don’t forget to save and run the job.

That’s it for the catalog price import. Export for the entity follows the same pattern. However, in addition to various sources and formats supported, you get the ability to extract data upon trigger events, perform consecutive export, etc.

To experience Improved Import and Export firsthand, explore the demo.

If you are interested in specifics of import or export of any other Magento 2 entity, look through our 

Guide List

'