Magento tax rates csv import fails with “Invalid file upload attempt”
If you try to import tax rates from a different multi-store installation, or even from staging, it often fails with an error message: Invalid file upload attempt
This could happen for two reasons:
1 - exception.log: “$region_code” got invalid value null
The following error is appearing in the exception.log:
Variable "$region_code" got invalid value null; Expected non-nullable type String! not to be null.
This is because an existing old tax rule contains no zip code. Make sure every tax rate has a zip code set up. If it should accept all zip codes,
it should be *
wildcard.
It’s often easier to truncate the tax_calculation_rate
table if the intent is to overwrite existing rates. Keep in mind, this means you will have to
redefine the rules.
2 - Invalid header row
This happens if the exported csv is from a store that has a different set of store views than the one we are trying to import to. In this case, click on “Export tax Rates” and copy the first line of the csv from the newly exported file to the one you would like to import.
Unfortunately, Magento does not provide a good explanation for the user about why the import failed and hopefully this post will help.
Comments