How to import transactions
Our extension allows data importing from other extensions using the CSV data format. The import transactions feature allows you to seamlessly transfer customer reward points data from other systems or previous setups into your current store. This is useful during migrations or when integrating external systems with your reward points program. By importing transactions, you ensure that your customers’ point balances are accurately reflected, maintaining their loyalty and engagement.
Unfortunately, we cannot add a download sample file due to Magento restrictions.
You can get a sample file by creating a manual transaction in Marketing -> Reward Points -> Transaction and then exporting it using the Export -> CSV action of the Grid.
How to import transactions data
- Extract data from your Reward Points extension to the CSV file, so that it contains the following columns (each line of that file would consist of transactions):
- transaction_id - a unique ID of each transaction. Can be a simple counter.
- customer_name - the first and last name of the customer.
- customer_email - the email of the customer.
- customer_group_name - the name of the in-store customer group the customer is assigned to.
- amount - the number of points that will be uploaded in the current transaction.
- comment - comment on the current transaction.
- created_at - the date the transaction was made. Extremely useful for uploading legacy transactions.
- expires_at - the expiration date uploaded in the transaction.
- code - code of action (upload in this case). It is recommended to use the same code for all uploaded transactions so that, if the upload was incorrect, the transactions can be easily removed.
- is_expired - whether uploaded points have expired. This is useful when uploading legacy transactions to maintain balance history.
- is_expiration_email_sent - whether an expiration email is sent. Typically 0, as this does not affect uploads.
- amount_used - the number of points used. Typically, this is set to 0. If there is no zero value, then the difference between this and the above will be uploaded.
- website_id - should contain not the actual Website ID, but its code, according to your M2 store view setup. base is the most common code used by default.
If you're importing data from the Mirasvit Reward Points extension, you can use a special migration script.
It will extract your data directly into the /tmp/points_export.csv
file. Feel free to modify the SQL query to suit your needs.
- Go to System -> Data Transfer -> Import, and on the drop-down menu Entity Type, select Reward Points Transactions. You will see the following options:
-
Import behavior - defines which action should be performed. Currently supported options:
- Add/Update - adds or updates transactions (if transaction_id matches).
- Replace - replaces transactions regardless of their existence.
- Delete - deletes all transactions with no IDs in the import file. Useful for cleaning up incorrect uploads.
-
Validation strategy:
- Stop on Error - stops importing if errors are found.
- Skip Error Entries - uploads valid data while skipping erroneous entries.
-
Allowed errors count - used if Stop on Error is selected, and it determines the number of errors allowed.
-
Field separator, Multiple value separator, and Fields enclosure are CSV parameters. Ensure they match your file format.
-
File to import - specifies the data file to import:
- Select file to import - drop the CSV file that you exported in the previous step here.
- Images file directory - used if links to images are included in the exported file. Typically, this is not used.
Magento 2 Import function may have restrictions on file size. By default, it's set to 2MB. To increase this limit, open your .htaccess
file and enter the following options (let's increase the limit to 40MB):
php_value upload_max_filesize 40M
php_value post_max_size 40M
Select the appropriate options, and press Check Data. This will validate the data.
- After validation is completed, you will see messages with any errors found under the options section. If data validation passes (the number of errors did not exceed the Allowed errors count parameter), the Import button will appear. Press it to import the transactions.
You can also upload only the customer's balance. Just treat them as transactions per customer.