Skip to main content

How to import transactions data

Our extension allows data importing from other extensions using the CSV data format.

Note

You can get a sample file by visiting the transactions page and then exporting it using Export -> CSV action of the Grid.

  1. Extract data from your Store Credit 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 simple counter;
    • customer_name - first and last name of the customer;
    • customer_email - customer email;
    • updated_at - date and time the transaction was updated;
    • balance_delta - change on the credit balance;
    • balance_amount - amount of funds available;
    • action - type of the transaction (refill, refund, use);
    • message - additional message sent alongside the transaction;
    • is_notified - displays if the notification was sent;
    • website_id - shall contain not actual Website ID, but its code, according to your M2 store view setup. base is the most common code used by default
  2. Go to System -> Data Transfer -> Import, and on the drop-down menu Entity Type, select Store Credit Transactions. You will see the following options:

  • Import Behavior - defines which action should be performed. Currently supported:

    • Add/Update - adds or updates of transactions (if transaction_id matches);
    • Replace - replaces transactions regardless of their existence.
    • Delete - deletes all transactions with no IDs on the import file. Useful for cleaning up incorrect upload.
    • Validation Strategy:
      • Stop on error - stops importing, if errors are found;
      • Skip error entries - upload data as valid data will be uploaded, while others will be dropped off.
    • 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, make them match your file format.
  • File to import - specifies the data file to import.

    • Select file to import - drop here CSV file, that you had exported in the previous step;
    • Images file directory - used, if links to pictures are used in the file exported. Typically it's not used at all.
    Note

    Magento 2 Import function can have restrictions on the file size. By default, it's only 2M. The best way to increase it is to - open your .htaccess file, and enter the following options (let us make a limit of 40M):

    php_value upload_max_filesize 40M
    php_value post_max_size 40M

    Select appropriate options, and press Check data. It will conduct data validation.

  1. After validation is finished, you will see the messages with errors found under the option section. If data validation is passed (errors' quantity did not exceed the Allowed errors count parameter), the Import button appears. Press it to import transactions.
Note

You can also upload only the customer's balance. Just treat them as transactions -per customer.