Matrixrates: CSV Import/Export

The CSV file can seem confusing at first, but spend 5 minutes with it and you will understand how it works, and see the flexibility it offers.

A CSV file is best opened with a spreadsheet application. At WebShopApps we prefer OpenOffice as it will save correctly on a Mac without issue and uses UTF-8.

Some facts about CSV configuration:

  • CSV tables are extensively used in our shipping extensions for creating rules
  • CSV files basically define the rules under which a shipping rate will show. Each row is a rule
  • If you don’t understand your shipping requirements you have little chance to make a CSV file that works. Get the requirements understood first
  • A CSV configuration is only as good as the person that writes it. If you write a bad CSV file then expect bad results
  • If you have no experience of spreadsheets/CSV files then go look this up first, it will help
  • If you are working on a Mac please ensure you save as Windows file type, else the csv will not upload
  • The shipping extension works on a “best match” basis. This means it will look for the tightest match first, and then work backwards if none can be found. If you have two rows in the table, one with country code “US” and one with “*”, then a customer from the US will match on the US row and a customer from UK will match on the “*” row.

How to Upload a CSV File

  1. Navigate to your Extension Configuration panel under Stores->Configuration->Sales->Shipping Methods
  2. Change Store View to be Main Website or the WebSite you wish to upload to in the case of multiple stores
    M2_Configuration_Scope
  3. You should now see an import button box appear with a browse boxCapturFiles-01-20-2016_11.20.05
  4. Browse for your CSV file you have setup (or use an example)
  5. Save Config to import the table. Any errors in the CSV will be reported here
  6. You should then see the appropriate shipping rates appear on the front end upon checkout

How to Export a CSV File

CSV files from Matrixrates are exported directly from the webshopapps_matrixrate database table.

Follow the above steps for Importing and you will also see an “Export” option, just above the “Import” option.

Exporting The CSV via phpMyAdmin

Alternatively, if the solution above is not appropriate, you can export the raw shipping data using phpMyAdmin. This data has been manipulated to get into the database so bear in mind that you will need to translate it back into a CSV importable format.

  1. Find the table called webshopapps_matrixrate and click on it
  2. Select the export tab at the top of the page
  3. Select the export as CSV option
  4. Export the csv
  5. Remove the columns “pk”, “website” and “cost” from the CSV file
  6. If applicable change the region codes back to region names (per the directory_country_region table).
  7.  If there is a “0” (zero) in the region column you need to delete this as Magento will see it as an invalid code when uploading
  8. Check the csv columns match the template  csv for your extension

You should end up with a CSV file similar in layout to the screenshot below:

CapturFiles-01-31-2016_11.31.07