Can't use IF statement in Expression Editor when importing products / IF function is working tho

Can't use IF statement in Expression Editor when importing products / IF function is working tho

Avatar image
Mar 17, 2013
Antoine wrote
Hello,

Can someone explain what I'm doing wrong here?? I use the expression editor when importing my products in Prestashop. I use it for category (but tested it on others) and this is what happens.

When I use IF function I get the result I expect. When I use an IF statement however I get Mysql errors.

WORKING -> IF([CSV_COL(8)]='DVD' ,CONCAT('OK'), CONCAT('NOK'))

NOT WORKING ->

IF([CSV_COL(8)]='DVD') THEN CONCAT('OK')
ELSE CONCAT('NOK')
END IF

In my eyes, these are exactly the same things ?? Or am I missing something here??

When I use the second i get these errors:

Cannot evaluate expression "IF('DVDs'='DVD') THEN CONCAT('OK')
ELSE CONCAT...". Error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') THEN CONCAT('OK')
ELSE CONCAT('NOK')
END IF' at line 1"

I don't want to use the IF function, I actually want to use the CASE statement, but got errors there, and then tried the IF ... same result ... no result ;-)

Anyone please :-)

Thnx,

Antoine
Reply
1 Answer
Avatar image
Mar 18, 2013
Dmytro Grycelyak agent wrote
Hello,

You should try to use the following expression:
CASE
WHEN ([CSV_COL(8)]='DVD') THEN CONCAT('OK')
ELSE CONCAT('NOK')
END
If you want to use a CASE function, than you should use WHEN operator.