1064 SQL Syntax Error after saving a product

  • Posts: 256
  • Thank you received: 2
8 years 7 months ago #213482

-- url of the page with the problem -- : 176.32.230.251/sewcharming.co.uk/
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.3.28
-- Browser(s) name and version -- : Chrome 45.0.2454.85
-- Error-message(debug-mod must be tuned on) -- : 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 1 SQL=INSERT IGNORE INTO fpz1c_hikashop_product_category (category_id,product_id,ordering) VALUES (12,2,);

Hello, I have been trying to save a product but every time I do it creates this 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 1 SQL=INSERT IGNORE INTO fpz1c_hikashop_product_category (category_id,product_id,ordering) VALUES (12,2,);

I have only just installed Hikashop and I didn't get any errors upon installation. I created categories fine it was only when I began to create a product and save it the error displayed. I have tried a few times and still getting the same error.

Regards,
Karen

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
8 years 7 months ago #213487

Hi,

Change the line:

$insert[]='('.$entry.','.$status.','.@$olds[$entry]->ordering.')';
to:
$insert[]='('.$entry.','.$status.','.(int)@$olds[$entry]->ordering.')';
in the file administrator/components/com_hikashop/classes/product.php and that will fix the problem.

Please Log in or Create an account to join the conversation.

  • Posts: 256
  • Thank you received: 2
8 years 7 months ago #213491

Thank you that worked. What would cause this issue from a fresh install. Or is it an error in the code that needs to be corrected?

Please Log in or Create an account to join the conversation.

  • Posts: 26008
  • Thank you received: 4004
  • MODERATOR
8 years 7 months ago #213497

Hi,

Like explained in the previous message, It is a line in the code that need to be modified.
The package is already up-to-date for that fix.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
8 years 2 months ago #228466

I am suffering the same with HikaShop 2.6.1, also looked for the code and is already the replacing one as suggested in your solution.

this is the fool message:

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 1 SQL=INSERT IGNORE INTO s3ni1_hikashop_product_category (category_id,product_id,ordering) VALUES ;

working in local site at this moment so can't offer an acces.

any suggestion?

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
8 years 2 months ago #228507

Hi,

Well, it's not the same error so the fix will be different.

The error you have is really strange because it means that you're creating a product without any category, but normally in that case, the "product category" is added automatically to the product.
So I can only suppose that you deleted it or something ?

Try changing the line:
if(empty($element->categories) && $element->product_type == 'main') {
to:
if((empty($element->categories) || !count($element->categories) ) && $element->product_type == 'main') {

in the file administrator/components/com_hikashop/classes/product.php and try again.

The following user(s) said Thank You: PeterChain

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
8 years 2 months ago #228524

Thanks Nicolas, I will try this later in the day and also put the experimental site online so I can give you access if we should explore further.

Thanks for the clear explanations and the code suggestion.

regards

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
8 years 2 months ago #228682

I tried this code tweak with not full success, just half.

I applied the changes to both sites the one exporting CSV and the one importing CSV,

Since then the problem is not reproducing if the exported data is of an already existing product in the Target Site.

But if I create a new product in Site A, then export, then import in site B this message persists.

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 1 SQL=INSERT IGNORE INTO s3ni1_hikashop_product_category (category_id,product_id,ordering) VALUES ;

This happens both for a NEW made product and for a NEW copied from an exiting one, without anything changed except for the 'copy_23764527" number that is automatically generated.

Both NEW and NEW copied products are made in HikaShop Backend.

Both sites are live if you would like to check, you have the access to them in your contact@ mailbox. They were sent today at 8:44 French time.

Access is in third page of PDF. That report is not directly related to this problem.

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
8 years 2 months ago #228769

Hi,

So the issue is with your CSV.
What you're saving is a product entry where the "product_type" is neither "variant" nor "main" and that's not possible as these are the only two types that exists.
That's why you get the error.

I've added a patch on our end to avoid the error but that should normally not happen. I've updated the install packages on our end so you can download it again and install it again on your website and you'll get the patch to avoid that.

The following user(s) said Thank You: PeterChain

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
8 years 2 months ago #228804

Big thank you Nicolas for attending this. I will test this early tomorrow and report to you.

but what it goes beyond my understanding is why my product don't have a defined type (product or variant'. Where and when should this happen.

If I create products from the HikaShop backend shouldn't they get the type assigned?

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
8 years 2 months ago #228809

Hi Nicolas,

after your advise this is what i did:

Updated HikaShop to 2.6.1 latest version HikaShop Business 2.6.1 [1602031626] in both sites.

created a new product.
modified an existing product.

exported CSV. checked the CSV to make sure it contains the new product and the modified product. It does.

Imported with the mass action on my target site.

No error 1064 anymore. But no new product imported. modified product that was already existing in target site gets updated (changes were affecting product_name and product_code, so I understand the update has been made by matching the product_id).

Should some extra setting be defined to also accept new products?

Shouldn't the system update productsby matching product_code instead of product_id ? By now I am testing with cloned sites but in a real world I will update to sites where the same product only shares the product_code but not the product_id.


UPDATE:

Although probably not directly related later I installed the new massaction plugin released today by Xavier and replaced the classes/massaction.php file.

Tested with both modified products and new products again and the situation keeps exactly the same.

SECOND UPDATE:

I will be available most of the day for immediate testing any further code fix / improvement in the aim to make the import function add new products. I ignore if this situation is standard or specific to my sites. You have at your contact@ mailbox the access for both sites that was sent yesterday February 3rd at 8:44.

Thanks for the intensive implication you showed today in helping fixing these issues.

Last edit: 8 years 2 months ago by PeterChain. Reason: Striked unnecessary information I realized you are already aware

Please Log in or Create an account to join the conversation.

  • Posts: 26008
  • Thank you received: 4004
  • MODERATOR
8 years 2 months ago #228806

Hi,

By creating a product in HikaShop (or HikaMarket), you will create a product with "main" product_type.

If you don't see the products after the import, check if you find them in the hikashop_product table and if you do check their product_type. It can only be main or variant. If it's something else, it won't be found by HikaShop.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 8 years 2 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
8 years 2 months ago #228834

Hi Jerome,

the 1064 error was over after last Nicolas patch he asked me to install. But now the problem is that the import Mass action only updates products already existing by product_id, but is ignoring the import of new products.

According to a Mass Action filter they are all of the kind "main".



and I checked that both the field definition "product_type" and its value "main" are showing in the exported CSV.

so this information may get lost in the Mass Action Import operation,

Can you help?

––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
UPDATE:

After further testing and experimenting I could reduce the bug location to the CSV import Mass Action method (but don't know how to fix it)

So i open a new fresh thread with only the really necessary information

www.hikashop.com/forum/content-creation/...-matched.html#228838
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

Attachments:
Last edit: 8 years 2 months ago by PeterChain.

Please Log in or Create an account to join the conversation.

Time to create page: 0.107 seconds
Powered by Kunena Forum