Product Importer Updater Documentation for X-cart
Configuring CSV type importers
Here is an example of the raw data in an example CSV file.
#
#BCSE Import Example File # “Product Name”,Category,Price,SKU “Batmobile”,Superhero/transportation,1000000.00,255-507 “Light Sabre”,Starwars/weapons,1.00,255-508 |
|||||||||||||
If you opened this file in excel or open office you would get results similar to the table below. | |||||||||||||
|
Creating a new importer
First follow the product importer pro link in your admin menu and then click the button for add new importer
Importer Information
- Enter a unique name in the name field and any information you would like in the notes field.
Import Information
- The username and password must be filled in if you are running an import from a file on a remote server that is password protected with either FTP or .htaccess
- The URL field is to point to where the file is located. There are three different ways to enter this:
- For local storage use something like /home/pathtofile/yourxcartdirectory/file.csv
- For FTP use something like ftp://yourwebsite.com/file.csv
- For website access use something like http://yourwebsite.com/file.csv
- Timing (unit is seconds) – This is the minimum time between sequential runs of the given import.
- File Type – This is the type of file you will be importing from. In our example we are using a csv (comma separated values).
- Header – This tells the importer how many lines to skip before your data starts in our case there are 3 comments and 1 line of column headers.
- Encoding – This is the character set used by your import file it is very important to make sure you have the correct set selected.
Primary Field Mappings
This is the most complicated portion of using the importer. The minimum required fields are present by default. Additional fields may of course be added.
- Input type
- Field – this tells the importer that you are using a column value for your field mapping. Columns start at zero.
- Static Text – This will insert a static value provided by the importer interface for your field mapping.
- PHP – This will perform some php and the return value will be used for your field mapping
- Input value
- If your input type is field this is the number of the column you wish to use.
- If your input type is static text this is the text you would like to use.
- If your input type is PHP this is the code you would like to run on the input array to create the value used
- Output type
- This category determines the list of options presented for your output value.
- Output value
- This is where your input value is actually mapped to the product value
Examples
- Productcode or(SKU) using PHP on the array — Use PHP to manipulate the array pulling the 4 column and concatenating a prefix on to the SKU.
NOTE: Columns in php can be accessed using the array $P because we would like the 4th column (column number 3) we use the variable $P[3].
- Product name — In our file, this is the very first column. In order to pull this information use the field input type so we chose that from the drop down. The importer needs to know which column is being used. This information is in the first column and columns start at 0 so we enter 0 as our input value.
Output type and output value are chose for us by default for the minimum required field mappings.
- Forsale — This indicated whether or not you would like your imported items to be automatically available for sale in your store. For this example we want all products added to be immediately available for sale, so we chose the static text input type then we enter ‘Y’ as our input value. This will automatically assign ‘Y’ in the forsale attribute of all imported products.
- Main Category — The category is provided for us by our import file. It is the second column in our file and we want to use it directly so we chose the input type field and input value 1.
- Price — This is provided in the import file and is located in the third column.
Troubleshooting Product Importer Pro
If there are no messages when the import is ran then you must download this zip Once you have downloaded the file, unzip it and follow the instructions included in the readme.txt file
If the import runs but your products fail then you can look at more detailed log messages in the var folder of your x-cart site. Once in the var folder go into the tmp folder and the messages are in the pip_failures.txt file.
If the log messages are not detailed enough you can go to the bcse folder and open the bcse_config.php file. Then inside the bcse_config.php file change $debug_level and $failed_debug_level to a higher number than 0 (typically either 2 or 5)