In the document Setting up a cron job we explain how to run import and export jobs using the command line in RO CSVI. This is the preferred way of running cron jobs because this is generally not limited by the limitations imposed by running an import or export through the browser. However in some cases you may need to run a cron job using a URL on the frontend, in this document we explain how to set this up.
So the first step is to create a template and do the needed settings. This document explains on how to run VirtueMart Product Import using frontend. The same procedure can be followed for any import and export in RO CSVI.
Creating the template
A template can be created by following these steps:
- Go to Components -> RO CSVI -> Templates
- Click New
- Give the template a name, say for example VirtueMart Product import
- Set Action to Import
- Set Component to VirtueMart
- Set Operation to Product
- Click Next: Select Source
- Source is set default to Load from your computer. Change it Load from server or Load from FTP server and set a server location from where the import file has to be read.
- Click Next: Select options
- The default values are OK, change if needed.
- Click Next: Select fields
- Nothing needed here as we set to Use column headers as configuration in step 10.
- Click Next: Finalize
- All done here
- Click Close to return to the list of templates or Edit if you want to fine-tune the template further.
Adding the template fields
Template fields can be added by following these steps:
- Go to Components -> RO CSVI -> Templates
- Click on Template fields
- In the Search Tools select your template
- Click on New to add a single field or click on Quick Add to add multiple fields.
Quick Add
The Quick Add Option allows you to quickly add multiple fields to a template. It is not possible to set any settings per field here but that can be done after the fields have been added to the template.
Setting up the template
Now in the import template change Enable Frontend/cron field to Yes and Set a secret key for the template.
Creating menu item
To create menu item follow the steps
- Go to Joomla Menu >> Menu Items
- Click New
- Give a Menu title, say for example VirtueMart Product Import
- Select Menu item type >> Click on RO CSVI >> Select Import front-end
- Select the import template we just created
- Set the secret key as set in the template
- Save the menu item
Run import on Front-end
Now that the RO CSVI template and Joomla menu has been set. The menu link will be available on frontend. Click on the link so to run the import.
Using repeatable field values in front-end URL
RO CSVI supports including repeatable field values in front-end export. An example URL for export template to include sort fields in the URL is given below
https://mydomain.com/index.php?option=com_csvi&view=export&csvi_template_id=XX&exportto=tofront&key=XXXX&task=export&tmpl=component&form_sortfields[0][name]=alias&form_sortfields[0][sortby]=ASC&form_sortfields[1][name]=catid&form_sortfields[1][sortby]=ASC
A menu item can also be created and the URL will then look like this.
https://mydomain.com/myexport?form_sortfields[0][name]=alias&form_sortfields[0][sortby]=ASC&form_sortfields[1][name]=catid&form_sortfields[1][sortby]=ASC
alias and catid are the fields included for sort fields. The ordering of fields is ASC for ascending, but this can also be set to DESC for descending.
Using multiple filter field values in front-end URL
If an export template has filters which supports multiple values. Those multiple filter values can be included in URL separated by |. For example in Joomla content export template, if you want to export data from multiple categories. Filtering can be set for these multiple categories in the URL. See the example below
https://mydomain.com/index.php?option=com_csvi&view=export&csvi_template_id=XX&exportto=tofront&key=XXXX@&task=export&tmpl=component&form_content_categories=8|9
A menu item can also be created and the URL will then look like this.
https://mydomain.com/myexport?form_content_categories=8|9
All the Joomla articles of category ID 8 and 9 will be included in export.