# DJ-Catalog2 CSV Import guidelines

## 1. General information

1. CSV file has to be UTF-8 encoded.
2. Only CSV files with ',' (comma) or ';' (semicolon) separators and single or double-quoted (' or ") text limiters/enclosures are supported.
3. CSV file must contain column headers, e. g. 'name', 'description'.
4. Order of columns within CSV file is not important.
5. All ID columns (e.g. product ID, category ID, group ID, etc.) should contain valid IDs (pointing to values that already exist in the database). Be carefull, as those values are not being validated.
6. If you want to import images and/or attachments they has to be uploaded before, via FTP, repectively to:
   - `/media/djcatalog2/import/images/`
   - `/media/djcatalog2/import/files/`
7. Depending on which type of data (product, category, producer) you want to import, you can choose default values for some columns (if they are not provided in CSV file). For example, if you do not provide `cat_id` value (or column, at all) for a product, then chosen 'Default Category' will be used instead.
8. Some server settings may not allow you to import large amount of data and the import process may be stopped in the middle. If you exceed 'maximum execution time' or 'memory limit', try importing data in smaller portions - for example 50-100 products at a time.
9. Please make a back-up of your webiste, before importing, especially if you use import function to update existing records in your database.

## 2. Product import

List of valid column names and their description:

Column name | Required | Notice
--- | --- | ---
`id` | No | If provided, has to point to existing product. Product will be updated then with the provided data for CSV file. If ID is empty (or 0), a new product will be created.
`name` | Yes | Should be unique within product's category, because based on product's name, an alias is being generated. Therefore there cannot be two products with the same alias.
`alias` | No | ---
`group_id` | No | ID of product's field group.
`cat_id` | No | ID of product's category.
`producer_id` | No | ID of product's producer.
`description` | No | Full description. Can contain HTML code.
`intro_desc` | No | Short description. Can contain HTML code.
`price` | No | Regular price. Should be a valid floating point number or an integer. Dot should be used as decimal point, e.g. 1099.95
`special_price` | No | Discount price. Should be a valid floating point number or an integer. Dot should be used as decimal point, e.g. 1099.95
`metatitle` | No | meta-title.
`metakey` | No | meta-keywords.
`metadesc` | No | meta-description.
`published` | No | State [0/1]. 0 = un-published, 1 = published.
`featured` | No | Featured product flag [0/1]. 0 = not featured, 1 = featured.
`ordering` | No | Integer number indicating product's order within its category.
`created` | No | Creation date in Date-Time format: [RRRR-MM-DD HH:MM:SS] or [RRRR-MM-DD].
`created_by` | No | ID of the Joomla! user who should be the owner of the product.
`images` | No | Comma-separated list of file names that should be located in /media/djcatalog2/import/images/ directory. For example: image1.jpg,image2.jpg,image3.jpg
`files` | No | Comma-separated list of file names that should be located in /media/djcatalog2/import/files/ directory. For example: chart1.pdf,manual.pdf

### Example 1

name | description | intro_desc | price | special_price | featured | images | files
--- | --- | --- | --- | --- | --- | --- | ---
Crystal vase | Very beautiful crystal vase from XVI century. | Nice crystal vase. | 1200.00 | 99.95 | 1 | vase1.jpg,vase2.jpg |
TV set | 40", Full HD LCD television set | Real must-have | 2999.00 | 2699.95 | 0 | tv40.jpg | manual.pdf,chart.xls

### Example 2

Notice that some records doesn't have any values in 'id' column - these will be new products in the database.
Also, 'cat_id' and 'producer_id' are IDs of already existing categories and producers.
id | cat_id | producer_id | name | price
--- | --- | --- | --- | ---
24 | 2 | 4 | Updated product | 599.00
25 | 2 | 5 | Updated product #2 | 499
| 2 | 6 | New product #1 | 1999
| 2 | 6 | New product #2 | 300.00

## 3. Category import

List of valid column names and their description:

Column name | Required | Notice
--- | --- | ---
`id` | No | If provided, has to point to existing category. Category will be updated then with the provided data for CSV file. If ID is empty (or 0), a new category will be created.
`name` | Yes | Should be unique within category's parent category, because based on category name, an alias is being generated. Therefore there cannot be two sibling categories with the same alias.
`alias` | No | ---
`description` | No | Full description. Can contain HTML code.
`metatitle` | No | meta-title.
`metakey` | No | meta-keywords.
`metadesc` | No | meta-description.
`published` | No | State [0/1]. 0 = un-published, 1 = published.
`ordering` | No | Integer number indicating category's order within its parent category.
`created` | No | Creation date in Date-Time format: [RRRR-MM-DD HH:MM:SS] or [RRRR-MM-DD].
`created_by` | No | ID of the Joomla! user who should be the owner of the category.
`images` | No | Comma-separated list of file names that should be located in /media/djcatalog2/import/images/ directory. For example: image1.jpg,image2.jpg,image3.jpg

### Example 3

Notice that all ID columns are empty. This script will only add new categories, assuming that there already exists a category with ID=1.
id | parent_id | name | description | images
--- | --- | --- | --- | ---
| 1 | Cars | All available cars. | cars.jpg
| 1 | Motorbikes | Full range of our motorcycles. | bikes.jpg
| 1 | Trucks | The biggest 18-wheelers. | truck.png

## 4. Producer import

List of valid column names and their description:

Column name | Required | Notice
--- | --- | ---
`id` | No | If provided, has to point to existing producer. Producer will be updated then with the provided data for CSV file. If ID is empty (or 0), a new producer will be created.
`name` | Yes | Should be unique, because based on producer's name, an alias is being generated. Therefore there cannot be two producers with the same alias.
`alias` | No | ---
`description` | No | Full description. Can contain HTML code.
`metatitle` | No | meta-title.
`metakey` | No | meta-keywords.
`metadesc` | No | meta-description.
`published` | No | State [0/1]. 0 = un-published, 1 = published.
`ordering` | No | Integer number indicating producer's order.
`created` | No | Creation date in Date-Time format: [RRRR-MM-DD HH:MM:SS] or [RRRR-MM-DD].
`created_by` | No | ID of the Joomla! user who should be the owner of the category.
`images` | No | Comma-separated list of file names that should be located in /media/djcatalog2/import/images/ directory. For example: image1.jpg,image2.jpg,image3.jpg

### Example 4

Following example will add 3 new producers and update 2 existing ones (IDs 1 & 2).
id | name | description | images
--- | --- | --- | ---
1 | Car manufacturer 1 | Lorem ipsum dolor sit amet... | cf1.jpg,cf2.jpg
2 | Car manufacturer 2 | Lorem ipsum dolor sit amet... | cf3.jpg,cf4.jpg
| Car manufacturer 3 | Lorem ipsum dolor sit amet... | cf5.jpg
| Car manufacturer 4 | Lorem ipsum dolor sit amet... |
| Car manufacturer 5 | Lorem ipsum dolor sit amet... | cf6.png,cf7.jpg