Using the RO CSVI Conditional rule plugin it is possible to replace values during import and export based on given conditions. Since the RO CSVI 7.20.0 version, there has been some improvements made for this rule plugin with the conditional checks, so that it is possible to replace a field with the value of another field using a rule. Not only can you replace a value but you can also set where the new value should be applied to. This can be the same field but also another field. With this document we will explain with a simple example on how to do this conditional check.
Let us consider when the product price value is equal to 12, we need to delete the price so price_delete field should get value Y on import. Here we explain on how to achieve this condition step by step.
1. Create VirtueMart Price import template
2. From RO CSVI Rules page, create a new rule for RO CSVI Conditional rule.
Lets us see what each section of the rule does here.
Compare that value is
This section is to check on what condition the values are checked. Options available are Equal to, Greater than, Less than and Empty.
Enter the value to check with. So if we select Greater than in "Compare that value is" section and if we enter value 20 in Value field. Field value is checked if it is greater than 20.
If the condition is satisfied, which value should be replaced with, Given value uses the value from Field/Value section. Value from given field will replace the value from field, in this case you need to enter the field name in Field/Value section.
Field to replace
This section has two options, Same field will replace the field value as given in Field/Value. Given field option will use the field entered in Value section.
Field name whose value should be replaced.
3. Apply this rule on product_price field in RO CSVI Template fields page
4. Import file contains three lines including headers with the below content
product_sku,product_price,price_delete 10001,10, 10002,12,
5. When we run import with the above sample content, as per our rule, price_delete field in first row should get empty value as value of product_price is less than 12. Second row price_delete field should get value Y as the value is equal to value 12. Import preview page should show the rule applied on price_delete field.
6. Run import and check if the product price with value 12 has been deleted.