How can I use custom SQL Expressions during import?

How can I use custom SQL Expressions during import?

Avatar image
Dec 18, 2014
Pablo Gonzalez agent wrote
I want to use a Subquery similar to:
CONCAT([CSV_COL(2)],'|', (SELECT entity_id FROM `/*PREFIX*/catalog_category_entity_url_key` WHERE `/*PREFIX*/catalog_category_entity_url_key`.`value` = 'CSV_COL(2)'))

I'm getting 2 kind of errors: No Database Selected or Table Doesn't Exist.

Is it possible to use a subquery inside an expression? In affirmative case, can you give me a working example so I can build my own?

Thanks,
Edited by Ira Kobylianska on Dec 19, 2014, 06:11 AM
Reply
5 Answers
Avatar image
Dec 19, 2014
Ira Kobylianska agent wrote
Hello Pablo,

Thank you for your comment.

Store Manager does not allow to use a sub-query inside an expression.
As workaround, we can offer you to export url_key values to the file and add it to the file that you are trying to import. After that you can use expression during import to set your rules based on url_key column.

Let us know if you have more questions
Avatar image
Dec 19, 2014
Pablo Gonzalez wrote
Hi Ira, thanks for answering.

Can you give me a detailed way to do what you prupose?

It will be really helpful for me.

Thanks,
Avatar image
Dec 22, 2014
Ira Kobylianska agent wrote
Hello Pablo,

Thank you for your interest

We exported from our database 3 fields - Name, path and url_key. In order to specify Category path based on url key, you can use the following expression:
CONCAT([CSV_COL(2)], '|', [CSV_COL(3)])
http://screencast.com/t/MFg0PFwoCE

where, x = number of csv column for url_key

In case you meant something else, please clarify what do you want to get after import, so we could help you

Waiting to hear from you
Avatar image
Dec 23, 2014
Pablo Gonzalez wrote
Hi Ira,

Thanks for your response.

I have a quick question, is it possible to use a SQL query that pulls data from the database and not the CSV file? Like SELECT value FROM table WHERE id = ?

Thanks,
Avatar image
Dec 24, 2014
Ira Kobylianska agent wrote
Hello Pablo,

Thank you for your question.

If you mean that you want to use SQL during import, then unfortunately no. There is no way to use SQL requests at Expressions fields, since import works with current database field only. Please note, that it will slow-down import if we add the possibility to run SQL statements and retrieve data from other database fields

Let us know if you have more questions