Lost password?    Lost username?    Register

Cron support, how does it work?

Attention: open in a new window. Print

A new file has been added to the program that handles the cron requests, this is the file cron.php. This file can be called directly from the command line. The file is located in /administrator/components/com_csvivirtuemart/helpers/cron.php it is called like this:

php /administrator/components/com_csvivirtuemart/helpers/cron.php

Arguments

There are several arguments that need to be passed on to make the cron work. These arguments are:

  • username

This must be a known admin user in the Joomla system

  • passwd

The password belonging to the supplied username.

  • template_name

The name of the template that needs to be used. This must exactly match the name of the template in the template list.

  • filename
The name of the file to import. This is only used for imports

 

Including the arguments the full command for an import can look like this:

php /administrator/components/com_csvivirtuemart/helpers/cron.php username="admin" passwd="admin" template_name="CSVI Product import" filename="/home/me/mygreatstock.csv"

Including the arguments the full command for an export can look like this:

php /administrator/components/com_csvivirtuemart/helpers/cron.php username="admin" passwd="admin" template_name="CSVI Product export"

Make sure this command is all on one line. In a cronjob you cannot span an entry across multiple lines. The assumption here is made that the PHP command is in the global path statement, otherwise the full path for PHP should be provided too. From CSVI VirtueMart 2.0 there is a cron command line generator included in the program.

Template settings

All settings from the template will be used when importing or exporting data.

 

Exporting to a local filename

To export to a local filename you need to fill in two settings in your export template.

  1. Filename for exported file
    This option is on the Settings tab
  2. File location
    This option is on the General settings tab
When the cronjob runs it will combine the file location and filename together to create the exact location.

Using the extra export options

When manually exporting orders for example, the export screen has a number of filters. These filters can also be used in the cron version too. As opposed to the manual export, the cron export can only take a single value per filter. To use these filters you need to know the name of the filters. These names are currently in use:

  • Standard export
    exportto
    localfile
    recordstart
    recordend
  • Order export
    ordernostart
    ordernoend
    ordergroupby
    orderdatestart
    orderdateend
    orderstatus
    ordercurrency
    orderpricestart
    orderpriceend
    orderuser
    orderproduct
    order_address
The harder part is finding out what values you can use for the filter. Here a list of how the values are determined:
Filter name Filter value
exportto tofile
localfile Full path excluding trailing slash
recordstart A number
recordend A number
ordernostart A number
ordernoend A number
groupby 0 for no grouping or 1 for grouping
orderdatestart A date in the format of "14-01-2009 13:02:55"
orderdateend A date in the format of "14-01-2009 13:02:55"
orderstatus The order status code as defined in VirtueMart order status types
ordercurrency The currency code as defined in VirtueMart currency list
orderpricestart A price value
orderpriceend A price value
orderuser The user ID as defined in Joomla user configuration
orderproduct The product SKU
order_address BT for Billing Address or ST for Shipping Address


To apply a filter to your cronjob the command will look like this:

Explanation
Command
Export all confirmed orders php /administrator/components/com_csvimproved/helpers/cron.php username="admin" passwd="admin" template_name="order_export" orderstatus="C"
Export all confirmed orders with the Euro currency
php /administrator/components/com_csvimproved/helpers/cron.php username="admin" passwd="admin" template_name="order_export" orderstatus="C" ordercurrency="EUR"
Export all confirmed orders with the Euro currency for product KY3
php /administrator/components/com_csvimproved/helpers/cron.php username="admin" passwd="admin" template_name="order_export" orderstatus="C" ordercurrency="EUR" orderproduct="KY3"

 

The output

The output has been optimized for command line output, this means there is no HTML code. This can be forwarded (piped) to a file for later analyzes.

Our partner: BatteryKing.nl