
Originally Posted by
jsimoes1997
Hi, when I did the import of a file successfully but it says that it has a sql error what I'm doing is with a product of a category then I created a product with another category already created,
I am putting the product id as the primary key and when I enter the new product and the category name even with it already created it gives error.
The data in the file I'm importing is this:
Code:
v_products_model;v_products_id;v_products_type;v_products_image;v_products_name_1;v_products_description_1;v_products_url_1;v_products_name_3;v_products_description_3;v_products_url_3;v_specials_price;v_specials_date_avail;v_specials_expires_date;v_products_price;v_products_weight;v_product_is_call;v_products_sort_order;v_products_quantity_order_min;v_products_quantity_order_units;v_products_priced_by_attribute;v_product_is_always_free_shipping;v_date_avail;v_date_added;v_products_quantity;v_manufacturers_name;v_categories_name_1;v_categories_name_3;v_tax_class_title;v_status
swTTT;184;1;;SWITCH;TEST 1 FOR PRODUCT;;SWITCH;TESTE 1 DE PRODUTO;;;;;5;5;0;1;1;1;0;0;;2019-03-04 14:28:22;2;CISCO;Test;Teste;--none--;1
swswq;;1;;SWITCH 1;TEST 1 FOR PRODUCT 1;;SWITCH 1;TESTE 1 DE PRODUTO 1;;;;;6;6;0;1;1;1;0;0;;2019-03-04 14:28:23;3;CISCO;Test1;Teste1;--none--;2
The sql error that you are giving me is this:
Code:
MySQLi error 1064: 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 ')
WHERE
products.products_id=188' at line 8
When executing:
SELECT
products_to_categories.products_id,
products_to_categories.categories_id,
products.master_categories_id
FROM
products
LEFT JOIN
products_to_categories ON (products.products_id = products_to_categories.products_id AND products_to_categories.categories_id=)
WHERE
products.products_id=188
MySQLi error 1064: 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 ')' at line 2
When executing:
INSERT INTO products_to_categories (products_id, categories_id)
VALUES (188, )
MySQLi error 1064: 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 ')
WHERE
products.products_id=188' at line 8
When executing:
SELECT
products_to_categories.products_id,
products_to_categories.categories_id,
products.master_categories_id
FROM
products
LEFT JOIN
products_to_categories ON (products.products_id = products_to_categories.products_id AND products_to_categories.categories_id=)
WHERE
products.products_id=188
MySQLi error 1064: 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 ')' at line 2
When executing:
INSERT INTO products_to_categories (products_id, categories_id)
VALUES (188, )
I need help!! Its urgent.
Thanks for the time.
If I understand correctly besides that the error message provided does not appear to directly relate to the product being imported, it looks like the particular issue would be addressed by modifying line 1501 from:
Code:
'.TABLE_PRODUCTS_TO_CATEGORIES.' ON ('.TABLE_PRODUCTS.'.products_id = '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id AND '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id='.$v_categories_id.')
to:
Code:
'.TABLE_PRODUCTS_TO_CATEGORIES.' ON ('.TABLE_PRODUCTS.'.products_id = '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id AND '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id='.(int)$v_categories_id.')
This area of code has been redone in the next revision.
Also, what this seems to imply overall is that it sounds like you have product in the main category of the store (not in a sub-category) and have a sub-category in which a product is located). This configuration in a default store can cause display issues.
I say this because without the change provided above, if $v_categories_id is equal to 0, then the issue identified would occur. A $v_categories_id of 0 indicates that the product is assigned to the root of the store. Further have said that in part are dealing with an existing product that is in an existing category; however, an existing category doesn't have a categories_id = 0 because only the root has that. Then there is the issue of the products_id = 188 when the file indicates 184... Perhaps a typo, but important information. The other possible issue seems that the setting to select the primary id may be set to products_model even though the file contains a products_id and the products_model is assigned to more than one product.