I am using commerce_feeds 7.x-1.x-dev with feeds 7.x-2.x-dev and feeds_xpathparser 7.x-1.x-dev.
I created an XML product importer. Importing an XML file with 1 product works as expected. Importing an XML with 2 products returns a SQLSTATE[42000]: Syntax error or access violation: 1064 error.
Importing a CSV file with 2 products works as expected.
This bug has also been noticed in issue queue `Feeds Xpath Parser` at http://drupal.org/node/1314326 although it has been closed the problem still exists and the works as expected is not true.
I debugged the problem and I attached some screenshots to demonstrate the error.
The problem lies in function `FeedsCommerceProductProcessor.existingEntityId().
The SQL query is constructed:
$product_id = db_query("SELECT product_id FROM {commerce_product} WHERE sku = :sku", array(':sku' => $value))->fetchField();
But the $value parameter is an array of 2 elements (in case of xpath parser) and the construction of the mysql query is wrong.
Although I am an experienced programmer, I am a Drupal newbie with not enough module flow knowledge to fix the error. The problem lies in a difference between the parsed result from a feeds CSV and feeds XPATH importer. The function `FeedsCommerceProductProcessor.uniqueTargets()` returns different results for different importers.
| Comment | File | Size | Author |
|---|---|---|---|
| 1314326.bad_.mysql_.png | 176.63 KB | liad | |
| 1314326.csv_.importer.png | 162.4 KB | liad | |
| 1314326.xml_.importer.png | 212.6 KB | liad |
Comments
Comment #1
pcambraI'm afraid this is not a problem with commerce feeds, as the existing id method is a mirror of what feeds does for nodes, i.e. (code)
$nid = db_query("SELECT nid FROM {node} WHERE nid = :nid", array(':nid' => $value))->fetchField();If $value is not what you expect, it's probably on the xpath parser or data.