Troubleshooting WooCommerce Import Issues
Why you can’t import scraped data into your WooCommerce store and how to fix it.
When you try to import the products extracted from some website in your WooCommerce store and you get an error, the first thought is “Smth is wrong with the file”. However, upon reviewing the file you see that it contains all required fields and everything seems to be correct. So why does the import fail? The answer is in the log:
View import log to learn why the import failed
While there might be various reasons of import failure, most often, the errors are related to the image import. Here are the possible reasons and how to deal with them.
Error getting a remote image. Forbidden
WooCommerce Import Error – Forbidden
This error occurs upon importing WooCommerce products along with images from URLs. When WooCommerce is trying to download images from the link, it’s being blocked by the server providing the images.
- Import products and images separately.
- Use some external solution for import.
- Change User-Agent.
Download all images using some third-party tool or request image scraping with eScraper to get them uploaded to your server. After that, upload image files to the WooCommerce import directory. Then import products with the default WooCommerce import tool with image names specified in the CSV (no link should be in the file). Images will be assigned automatically.
Use Store Manager for WooCommerce to download images and upload them to WooCommerce without any limitations. Third-party tools offer images queue and multi-thread work for the upload, thus import goes smoothly with external image links. Download free trial: https://woocommerce-manager.com/free-download/
When WordPress is trying to download an image from another website, it is using the default User-Agent, e.g. “WordPress/5.7; http://example.com/”. Some websites might block all requests that have a User-Agent header other than web-browsers. So you have to provide a web browser User Agent to be able to access images. You can do this by installing a third-party plugin or editing a single line of code in one of the source files of your store.
The change should be made in the file: wp-includes/class-http.php
The line you need to find is:
'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $url ),
Replace that line with the following:
'user-agent' => apply_filters( 'http_headers_useragent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36' ),
Plugins are better in terms of that when you update your WordPress to a newer version the plugin will remain and keep working. If you edit the file manually, WordPress update will restore the wp-includes/class-http.php file to the default version and you will have to edit it again for future import procedures.
Sorry, this file type is not permitted for security reasons
WooCommerce Import Error – Forbidden
One of the reasons for getting this error is using links to images with dynamic parameters. Dynamic parameters appear after the question mark (?). So the image is generated with these parameters:
Example of image with dynamic URL
- Change dynamic links to static ones.
- Use some external solution that supports import from dynamic links.
- Save images from links and upload them from a local disk/FTP.
To import images using the default WooCommerce importer, make sure that your image links are static and end with /imgagename.jpg or /imagename.png, the supported WooCommerce formats. The link should not contain any question marks because dynamic links with parameters cannot be imported with the default Woocommerce import tool.
To import images from dynamic links, use alternative tools like Store Manager for WooCommerce (free trial available here – https://woocommerce-manager.com/free-download/ ). The tool emulates browser download and performs import of the image file itself into WooCommerce.
You can request image files after scraping. We will download all image files for you. This option will cost additionally (depending on the volume of images and their size). You will then be able to upload the files to your server (import folder) before import and then upload products with image names to assign images to the products.
As you can see, the issues with the import of scraped data to WooCommerce can be either related to getting images from the source website (server restricts image download) or with the settings on your server that restrict the upload.
Please write in the comments if the methods offered above helped, or describe your case so that we could investigate it and offer possible solutions.