RO CSVI
Custom tables export
| RO CSVI
Requirements
- CSVI 6.0+
- Joomla 3+
Background information
The custom export is a special export which allows you to export data from any available database table in your system.
Creating the template
First we will create an export template in which we can store all our preference. Let's say we are going to do an custom table export
- Go to Components
- Go to RO CSVI
- Click on Templates page
Now you are on the templates page, this is where the import and export templates are created. Click on New button on top corner and follow the Create a template tutorial to create your template.
- Give a descriptive name for the template
- Select Export as Action
- Component as RO CSVI
- Operation as Custom tables
- Enable logging if set to Yes
This is a very important option. Setting this to Yes will tell CSVI to create a detailed log of all steps taken during export. This is a very useful report to find any potential problems. Whenever you post a question on the forum, make sure you post this file also. It is the only way to help you out. The How to collect debug information article explains this in further detail.
Setting the options
The next step is to tell CSVI for which custom table you want to export, from the options tab, select the table.
Now that the options are set, Don't forget to click on Save to save your changes in your template and make sure they don't get lost.
Adding the fields
Now that template is created we need to add fields to be exported. Fields depend on the custom table you have selected for exporting. In this tutorial, content table is taken as example, so for exporting from content table, fields are added like
Once the template and template fields are set, Exporting can be done in a normal way.
Supported tables
CSVI supports all tables that are supported in the Joomla installation to be imported/exported.
To know the avaialble fields which can be exported, take these steps:
- Go to Components -> RO CSVI -> Available Fields
- Select Export
- Select RO CSVI
- Select Custom tables
- Click on Go
- Click on the column Table to sort the fields on Table
- Now scroll to the table you want to export and you can see the fields that are available for exporting
Once template and template fields are set, the last step is to do exporting. To do this, go to Export tab and select the template you just created.
CSVI will prepare the export file and download it to your computer.
Once exported, logs and the exported filename will be displayed.
Field copy plugin
| RO CSVI
The Field copy plugin let's you copy a field value to another without creating columns to repeat the values during import.
From Components -> CSVI pro ->Templates tab -> Rules, Click New to add a new rule using field copy plugin.
For example to create a rule to copy product_desc to product_s_desc field for a virtuemart product.
- Give a meaningful name for the rule in name field say "Virtuemart field copy product"
- Select Action as Import
- Select Plugin as CSVI field copy
- Click on load plugin button
You will now see two new fields appears
Source field
The source field is the field that CSVI needs to copy from. The names to fill in here come from the template fields page. The source fieldnames must be the names that are found in the Field name column on the template fields page.
Target field
The target field is the one where CSVI needs to copy to. Same as the source field even this field has to come from the template fields page. This must always be a name found in the Field name column.
Example
Here is an example on how to create a rule for a field copy plugin.
Now set this rule to template fields to use the field copy plugin like below
When the fields are set with rules you can see a small fire icon next to the field name in Template fields tab.
Important Note :
- Make sure that both product_desc and product_s_desc (examples used in this template) are there in template fields list to use the field copy plugin.
- Use file for configuration option in templates->template name->file tab set to No.
Now that all rules and fields are set, CSVI will automatically copy the value from product_desc (source field) to product_s_desc (target field).
RO CSVI supported operations
| RO CSVI
In RO CSVI we offer a number of import and export routines to manage your data. This is the complete list of RO CSVI supported operations. The majority of operations are available for both import and export although some are for a specific task so they can only be used for either import or export.
Combine plugin
| RO CSVI
The combine plugin let's you combine multiple fields into a single field during import.
Source fields
The source fields are the fields that CSVI needs to combine. The names to fill in here come from the template fields page. The source fieldnames must be the names that are found in the Field name column on the template fields page. Unless the name in the Field name column is called combine. In that case you need to use the name found in the Your field column.
Target field
The result of the combination of the source fields will be put into this field. This must always be a name found in the Field name column.
Example
Combine with CSV import file
Say for example we have a CSV file with the following contents.
"product_sku";"product_name";"category_path";"subcategory1";"subcategory2"
"1001";"Product 1";""Shoes";"Women";"Flipflops"
"1002";"Product 2";""Shoes";"Men";"Runners"
"1003";"Product 3";""Shoes";"Kids";"Sneakers"
We need to combine sub categories into main category_path field then the below import explains on how to acheive this combine fields in import.
Here is a list of fields of a CSV file where we combine the fourth field. Since the combine is a special field it must have a name in the Your field column.
An example of complete import using a CSV file is shown below
Make sure that Use file for configuration setting in template settings on File tab is set to No so CSVI reads the template fields and not the column headers of the import file.
Combine with XML import file
We have a XML file to be imported with the below structure.
<?xml version="1.0" encoding="UTF-8"?>
<products>
<product>
<code>1001</code>
<titlos>Product 1</titlos>
<category>Shoes</category>
<subcategory1>Women</subcategory1>
<subcategory2>Flipflops</subcategory2>
</product>
<product>
<code>1002</code>
<titlos>Product 2</titlos>
<category>Shoes</category>
<subcategory1>Men</subcategory1>
<subcategory2>Runners</subcategory2>
</product>
<product>
<code>1003</code>
<titlos>Product 3</titlos>
<category>Shoes</category>
<subcategory1>Kids</subcategory1>
<subcategory2>Sneakers</subcategory2>
</product>
</products>
Here is a list of fields of an XML file where we combine the fourth field. XML files require that the Your field is filled with the name in the XML file, all fields here have the Your field filled with the XML path.
An example for complete XML import using combine fields is explained below
In the combine plugin we set these fields up as shown in the image here:
Looking at the Source fields, the category_path is a regular field, so we specify it as category_path. The subcategory field here is the combine field in the template list, as you can have multiple combine fields, CSVI would not know which combine field to use. That is why the Your field must be filled for the combine field. In the Source fields we use the Your field name.
The Target field is in this case the category_path but could also be another field, as long as it is a regular field and the name appears in the Field name column.
Have a look at Combining fields on Import and Export documentation to know more on combine rule plugin.
Conditional rule plugin for import
| RO CSVI
CSVI introduces a new conditional rule plugin so users can now run import and export of field values based on another field and its value. In this article we are going to explain on an example condition for import on VirtueMart order operation.
Lets say we are importing orders in VirtueMart and when order_total field is 0 in import file, the value of order_subtotal should be filled for order_total. The procedure is as explained.
We have an example file like
1. Create a order import template in VirtueMart
2. Create template fields for the order template.
3. Make sure that you set Use file for configuration to No in your template settings and on File tab. This way we tell CSVI to use template fields and not headers of import file.
4. Create conditional rule and set the rule against order_total field. The preview of the import would show the value of order_total field used from order_subtotal field. Check and run the import.