RO CSVI
Skip rule plugin in RO CSVI
| RO CSVI
RO CSVI has a flexibilty to skip the records on import and export based on any specific text. This can be achieved using Skip rule plugin.
The example document will explain how to skip records based on text in category_path field in import. The operation used here is VirtueMart product import.
Consider that the import file looks like the content in the below table and you need to skip the import of records with text cooper and reebok in category_path.
product_sku | product_name | product_desc | product_price | product_currency | product_in_stock | manufacturer_name | category_path |
NI091SH97UHYINDFAS | Nike Kaishi 2.0 Grey Sneakers | Nike presents these grey sneakers, especially designed for men who love to stay ahead in the style game. | 64.55 | EUR | 3 | Nike | shoes/nike/men/sneakers |
PU102SH00KOXINDFAS | Puma Sam Idp Navy Blue Flip Flops | Experience the blissful comfort as you wear these navy blue flip-flops from PUMA. | 61.2 | EUR | 5 | Puma | shoes/puma/men/flipflops |
LE080SH77ZDIINDFAS | Lee Cooper Black Loafers | Latest in fashion, these black coloured dress shoes from the house of Lee Cooper will look smart when teamed with your business suits! | 57.75 | EUR | 2 | Lee Cooper | shoes/leecooper/men/loafers |
AD004SH94JPDINDFAS | Adidas Zg Bounce Trainer White Training Shoes | Make your fitness sessions even more effective by wearing these white coloured ?Zg Bounce Trainer? training shoes for men by adidas. | 62.34 | EUR | 6 | Adidas | shoes/adidas/men/trainers |
RE105SH85GDYINDFAS | Reebok electrify speed running shoes | Reebok presents these black coloured 'Electrify Speed' running shoes, which will catch your fancy at once. | 68.99 | EUR | 4 | Reebok | shoes/reebok/men/runningshoes |
The first step is to create a product import 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. No need for change.
- 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.
Set the Use file for configuration to No in import template settings on File tab. Save the template.
Add the needed template fields for the template. 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.
Now create a Skip rule and apply the rule on category_path field.
- Go to Components -> RO CSVI -> Rules
- Click New
- Give the rule a name, say for example Skip categories
- Set Action to Import
- Select Plugin to CSVI Skip
- Method to match is Regular text
- Values to match as cooper,reebok
- Save the rule
- Set the rule on category_path field in template fields page.
Run the import. The import can be run by following these steps:
- Go to Components -> RO CSVI -> Import
- Select the template created earlier with name VirtueMart product import
- Click Select file
- Select the file to import
- Click Preview
- You now see a preview of the file as to how CSVI sees the file. Here you can also see that CSVI has skipped two rows with text cooper and reebok in category_path field. If you still see the rows then there is something wrong with your Skip rule setting. Cross check the settings again.
- Click Start import
- The import is run and you can see that CSVI showing messages in log details page that the rows are skipped because of skip rule settings.
- The Log details page will be shown with information regarding the import if the Enable logging is enabled in the template
Skip rule for Date expressions
Starting with RO CSVI 8.3.0 version, we are introducing a new feature of comparing date values using Skip rule so to skip a record based on dates.
Fields offered
- Select method to match as Date expression
- We offer three types of date selectors. Date before, Date after and Date equal. This acts as comparison operator to check the date values
- Date to check is offered with current date and input date. Current date will check the date value against today's date. Input date compares with the date as entered in Date value field with database value and skips the record if it matches the condition.
- Date format field is to set the format in which date value is compared. Default format is set to "Y-m-d H:i:s"
Example
Consider that you need to check for product_available_date field is more than a specific date(2022-04-15 00:00:00) in VirtueMart products export and skip those records. Set the Skip rule like the image below and apply the rule on product_available_date field in template fields.
I want to import VirtueMart products with images
| RO CSVI
Import product images in VirtueMart using CSVI with few steps. Learn how to do link images to products.
Date and Custom date in Multi replace plugin
| RO CSVI
Most of the times we would need to export or import today's date or a custom format date in our export and import operations. This can be now be easily accompolished using RO CSVI Multi replace rule plugin.
Date format on export
The example here explains on how to create a rule in Multi replace plugin for exporting today's date in your exports, the same can be followed for import too.
- Create a new Multi replace rule for export
- Select Operation as Date
- Under Filter section and Date format field enter the format you want to export date, for example like d-m-Y. Check for other date formats with PHP date documentation.
- Save the rule
- Apply the rule on your export template fields.
Running an export by setting Today's date export on custom template field, an example in export file will look like below
Date format on import
An example for import using date format for field created_on in VirtueMart Product import is explained below.
1. Create VirtueMart Product import template and add created_on as one of the field in import
2. This is the preview page before applying the date rule.
3. Now create a rule using Multi replace plugin with date as operation. Add a date format to the rule.
4. Apply the rule on created_on field
5. Run the import and check the preview page.
Custom date format
It is sometimes needed to change the date format you need to import or export from or to database. Custom date format operation in RO CSVI Multi replace plugin will help you with this. The below example explains changing date format for export, the same can be followed for import too.
Custom date format for export
- Create a new Multi replace rule for export
- Select Operation as Custom date format
- Under Filter section and Date format field enter the format you want to change the date to, for example like m.d.y
- Save the rule
- Apply the rule on your export template fields.
The default date format stored in database is Y-m-d H:i:s where Y is the year, m is the month, d is the date, H is the hour, i is the minutes and s is the seconds. You can change this default format to any needed custom format in your export and in import you can change the date format in your import file to database supported format. Check for other date formats with PHP date documentation.
An example export file created by applying Custom date format rule on created_on field in VirtueMart product export is shown below
Custom date format for import
Here in this example we are explaining about using custom date format to change the format of created_on date on VirtueMart product import to database supported format Y-m-d H:i:s.
1. Create a rule using Multi replace plugin
2. Create VirtueMart Product import template and add created_on as a template field. Apply custom date rule on created_on field.
3. Run the import and check the preview page.
More articles on this subject
Conditional rule plugin for export
| RO CSVI
CSVI introduces a new conditional rule plugin so value of one field can be exported based on another field and its value
In this example export we are going to check if product_price value is greater than a value say 50 and replace it with a new value 75.
1. Create a VirtueMart product export template. To do that create a new template with component as VirtueMart, operation as product and action to be export.
2. On template fields page add fields to be export. In this example we add
- product_sku
- product_name
- product_price
3. Create conditional rule for export and apply on product_price field in template fields page. Run the export and check the product_price field.
More articles on this subject
Creating own HTML export file
| RO CSVI
This article explains how to create your own HTML export file for personalised customisation. By doing this there is no core files modified so updating CSVI extension is easy and the personalised changes are not lost.
To do this, under the folder administrator\components\com_csvi\helper\file\export, look for the file csvimproved.php. This is the actual file which is used for exporting html content. To have your own file, make a copy of this file in the same location. Say for example we are making a copy of the file with name customhtml.php.
Now open the duplicated file and check for the text CsviHelperFileExportHtmlCsvimproved (class name in the file) change it to name matching to the name of the new file. Here it is customhtml.php so the text will be changed to CsviHelperFileExportHtmlCustomhtml and save the file.
On Joomla administrator interface, go to Extension >> Languages. Click on Override on the side menu. Select the override for the language you have as default. Remember we are doing the language override for administrator as it is for CSVI export template settings. For English, it is English(en-GB) - Administrator, click on the new button on top.
Create a language override string for the new class file we created just now and Save it.
Now the new custom html file will be available in the export template settings under file tab.