Set up the CSV interface

Import any CSV product feed into affiliate-toolkit: set feed URL, delimiter and import mode, map the columns and keep the products updated.

With the CSV interface you connect affiliate-toolkit to any product feed in CSV format: from affiliate networks such as AWIN, Webgains, Belboon or CJ, from a single merchant, or from a file you created yourself. affiliate-toolkit downloads the feed, imports it into its own database table and keeps it up to date. You then use the products like any other affiliate-toolkit product.

You need:

Want to build your own file instead? Read Create your own CSV file and import it via CSV.

Find the CSV feed URL

Most affiliate networks have a tool called "Create a Feed" or similar that builds the feed URL for you. This is AWIN's tool, for example; the feed URL is in the red box:

The Create-a-Feed tool in AWIN with the generated feed URL highlighted
A feed URL generated in AWIN

Copy the complete URL. Do not use a shortened link, it will not work.

Choose CSV as format, in UTF-8 if the network offers it. GZIP or ZIP compression is fine: select the matching import mode in the shop.

Requirements for your server

affiliate-toolkit downloads the feed and imports it into a database table of its own. A feed of 1 GB takes roughly 1 GB in your database, and some hosts limit the database size, so check this for large feeds.

The PHP option allow_url_fopen must be active. Without it, the shop shows a message that this setting should be enabled and cannot read the file.

Create the CSV shop

  1. Go to affiliate-toolkit → Shops and click Add new Shop.
  2. Enter a title. It is only used in the backend.
  3. Select CSV API as Data supplier.
  4. Paste the feed URL into CSV-URL, set delimiter, import mode and the other options described below.
  5. Click Publish. affiliate-toolkit downloads the file once and reads its columns. You then map them as described in the next section.
A CSV shop: feed URL, download mode, delimiter, encoding, header row and the import status of the feed.
A CSV shop with its feed settings

Fields of the CSV shop

FieldDescription
CSV-URLThe full feed URL from the network or merchant. Do not use a shortened URL.
CSV-EncodingLeave it empty for UTF-8 files. If special characters look wrong, enter the character set of the file, for example ISO-8859-1 for a Windows-1252 file. The text is converted to UTF-8 during the import.
Column delimiterThe character between the fields: Tabstopp, Pipe (|), Carret (^), Comma (,) or Semicolon (;). Check it in the feed tool of your network or open the file in a text editor.
Import modeHow the file is downloaded, see the table below.
First line is headerTick it if the first line contains the column names, as with most networks. Otherwise the columns are numbered.
Remove line breaks before import (only Webclient & Download)Removes line breaks inside quoted fields, for example in descriptions, which would otherwise break the import. Only works with the import modes Download and Web Client.
Character stringThe character that encloses text fields: Double quotes or Single quotes. It matters when a title or description contains the delimiter itself.
Wait x seconds before retrieve fileOptional waiting time before the download, 0 by default. You normally do not need it.
Ignore first x rowsSkips up to 20 lines at the start of the file, for example a summary above the column header.
Pre filter (one keyword per line)Imports only lines that contain at least one of the keywords, case-insensitive. Use it to keep large feeds small, for example to import "Technology" but not "Fashion".

Import modes

ModeHow it works
FilestreamReads the file in small blocks and writes it to your server. Saves memory, but not every host supports it.
DownloadLoads the whole file into memory with WordPress and then writes it to disk. Line breaks can be removed on the way.
Download & Gzip compressionDownloads a GZIP file with WordPress and unpacks it in blocks.
Web ClientLike Download, but the request is sent outside of the WordPress HTTP API. Also loads the whole file into memory.
Gzip compressionOpens a GZIP file as a stream and unpacks it in blocks while writing. Saves memory.
Zip compressionDownloads a ZIP archive and extracts the file it contains.

Map the columns

After the first save, the shop lists every affiliate-toolkit field. On the left you see the affiliate-toolkit field, on the right you select the matching column of your feed. Once data has been imported, a sample value is shown in brackets next to each column name.

The field mapping of the CSV shop: each affiliate-toolkit field (number, title, EAN, price, URL, images …) is assigned a column of the feed, with optional prefix, suffix and fallback.
Mapping feed columns to affiliate-toolkit fields

Number and Title are required. You can also map EAN, ISBN, GTIN, MPN, product group, description, features, price, list price, product URL, three image sizes plus three additional images, availability, shipping costs, manufacturer and brand. Each field has three optional helpers:

  • Prefix is added in front of the value. With the prefix https://, domain.com/prd1 becomes https://domain.com/prd1.
  • Suffix is added at the end. With the suffix ?ref=1, https://domain.com/prd1 becomes https://domain.com/prd1?ref=1.
  • Fallback is used when the column is empty for a product.

The rows Custom text 1 to Custom text 4 let you fill your own fields: choose the target field on the left and the feed column on the right. See User-defined fields for how to create them.

Import the feed

As long as the feed has not been imported, the shop is marked in orange with Download & Import required. You have two ways to load the data:

  • Wait for the cronjob. It downloads and imports the feed in the background. This is the recommended way for large files.
  • Import manually. Tick Download & Import CSV-files now at the bottom of the shop and save. This runs in your browser request and can hit a timeout with large feeds.

After the import, the shop shows how many lines were imported and, if some rows contained invalid data, how many could not be imported, with a few examples. In the shop list you also see Updated on with date and time.

The cronjob downloads the feed again in the interval set under affiliate-toolkit → Settings → General settings → CSV Import intervall: 6 hours, 12 hours, 1 day (default), 3 days or 1 week. Make sure your cronjob runs, see How to set up the cronjob for updates. If you change the CSV-URL or the import mode, the file is downloaded again when you save.

To force a fresh import of all CSV shops at once, use the button Mark all CSV shops for import on the debug page under affiliate-toolkit → Tools.

Database table and files

affiliate-toolkit creates a database table named {prefix}atkp_csv_{shop ID} for every CSV shop, for example wp_atkp_csv_1234. The downloaded file is stored as {shop ID}.csv in the folder /wp-content/uploads/affiliate-toolkit/.

When you move a CSV shop to the trash, its table and file are removed as well.

Import products and create lists

Open affiliate-toolkit → Product import, select your CSV shop and search the imported feed by keyword, EAN, GTIN or ISBN. Import the products you want; from then on they are updated after every feed import.

The product import searching the imported CSV feed for
Searching a CSV feed in the product import

CSV shops support search lists and advanced search lists. How to create them is explained in How to import and display your first list; how to place products on a page in How to import and display your first product and affiliate-toolkit WordPress shortcodes.

The column mapping does not appear after saving. What can I do?

affiliate-toolkit could not download or read the file. Check the status message of the shop, the CSV-URL (complete, not shortened), the import mode (GZIP and ZIP files need the matching compression mode) and the column delimiter. If only one long column is shown, the delimiter is wrong.

Special characters such as umlauts look wrong. How do I fix that?

The file is not UTF-8. Enter its character set in CSV-Encoding, for example ISO-8859-1, and import the feed again.

The import stops or rows are missing.

Large feeds can run into the PHP time or memory limit during a manual import. Let the cronjob do the import, use a memory-saving mode such as Filestream or Gzip compression, or reduce the feed with the pre filter. Lines that break inside a description can be fixed with Remove line breaks before import.

Can I import several feeds?

Yes. Create one CSV shop per feed. Each shop gets its own table, settings and column mapping.