Question about database structure

  • Posts: 43
  • Thank you received: 1
8 years 4 months ago #245094

-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.6
-- Browser(s) name and version -- : all
-- Error-message(debug-mod must be tuned on) -- : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OR category.category_id = 714 OR category.category_id = 715 OR category.category' at line 20 SQL=SELECT DISTINCT content.product_id AS id, content.product_name AS title, content.product_description AS text, contentR.product_modified AS date, contentR.product_created AS date_publish FROM #__hikashop_product AS content LEFT JOIN #__hikashop_product_category AS category ON category.product_id = content.product_id LEFT JOIN #__hikashop_product AS contentR ON contentR.product_id = content.product_id WHERE contentR.product_parent_id = 0 AND contentR.product_published = 1 AND ( category.category_id = 2 OR category.category_id = 3 OR category.category_id = 5 OR category.category_id = 10 OR category.category_id = 14 OR category.category_id = 18 OR category.category_id = 655 OR category.category_id = 656 OR category.category_id = 657 OR category.category_id = 658 OR category.category_id = 659 OR category.category_id = 660 OR category.category_id = 661 OR category.category_id = 662 OR category.category_id = 663 OR category.category_id = 664 OR category.category_id = 665 OR category.category_id = 666 OR category.category_id = 667 OR category.category_id = 668 OR category.category_id = 669 OR category.category_id = 671 OR category.category_id = 674 OR category.category_id = OR category.category_id = 714 OR category.category_id = 715 OR category.category_id = 716 OR category.category_id = 718 OR category.category_id = 719 OR category.category_id = 720 OR category.category_id = 721 OR category.category_id = 722 OR category.category_id = 723 OR category.category_id = 724 OR category.category_id = 725 OR category.category_id = 976 OR category.category_id = 979 OR category.category_id = 980 OR category.category_id = 981 OR category.category_id = 982 OR category.category_id = 983 OR category.category_id = 984 OR category.category_id = 985 OR category.category_id = 986 OR category.category_id = 987 OR category.category_id = 988 OR category.category_id = 989 OR category.category_id = 990 OR category.category_id = 991 OR category.category_id = 992 OR category.category_id = 993 OR category.category_id = 994 OR category.category_id = 995 OR category.category_id = 998 OR category.category_id = 999 OR category.category_id = 1000 OR category.category_id = 1001 OR category.category_id = 1002 OR category.category_id = 1003 OR category.category_id = 1004 OR category.category_id = 1005 OR category.category_id = 1006 OR category.category_id = 1007 OR category.category_id = 1009 OR category.category_id = 1010 OR category.category_id = 1012 OR category.category_id = 1013 OR category.category_id = 1014 OR category.category_id = 1015 OR category.category_id = 1016 OR category.category_id = 1017 OR category.category_id = 1018 OR category.category_id = 1019 OR category.category_id = 1020 OR category.category_id = 1024 OR category.category_id = 1025 OR category.category_id = 1026 OR category.category_id = 1027 OR category.category_id = 1028 OR category.category_id = 1029 OR category.category_id = 1032 OR category.category_id = 1033 OR category.category_id = 1034 OR category.category_id = 1035 OR category.category_id = 1037 OR category.category_id = 1038 OR category.category_id = 1039 OR category.category_id = 1040 OR category.category_id = 1041 OR category.category_id = 1042 OR category.category_id = 1043 OR category.category_id = 1044 OR category.category_id = 1045 OR category.category_id = 1047 OR category.category_id = 1048 OR category.category_id = 1050 OR category.category_id = 1051 OR category.category_id = 1052 OR category.category_id = 1053 OR category.category_id = 1054 OR category.category_id = 1055 OR category.category_id = 1056 OR category.category_id = 1057 OR category.category_id = 1058 OR category.category_id = 1059 OR category.category_id = 1060 OR category.category_id = 1061 OR category.category_id = 1062 OR category.category_id = 1063 OR category.category_id = 1064 OR category.category_id = 1065 OR category.category_id = 1066 OR category.category_id = 1067 OR category.category_id = 1068 OR category.category_id = 1077 OR category.category_id = 1078 OR category.category_id = 1080 OR category.category_id = 1081 OR category.category_id = 1082 OR category.category_id = 1083 OR category.category_id = 1084 OR category.category_id = 1085 OR category.category_id = 1087 OR category.category_id = 1089 OR category.category_id = 1090 OR category.category_id = 1091 OR category.category_id = 1092 OR category.category_id = 1093 OR category.category_id = 1094 OR category.category_id = 1095 OR category.category_id = 1096 OR category.category_id = 1097 OR category.category_id = 1098 OR category.category_id = 1099 OR category.category_id = 1100 OR category.category_id = 1101 OR category.category_id = 1102 OR category.category_id = 1103 OR category.category_id = 1108 OR category.category_id = 1110 OR category.category_id = 1111 OR category.category_id = 1112 OR category.category_id = 1113 OR category.category_id = 1114 OR category.category_id = 1116 OR category.category_id = 1117 OR category.category_id = 1118 OR category.category_id = 1119 OR category.category_id = 1120 OR category.category_id = 1121 OR category.category_id = 1127 OR category.category_id = 1135 OR category.category_id = 1136) ORDER BY contentR.product_created DESC LIMIT 0,8;

I need some help to understand your database structure. We migrate huge online store from K2 to hikashop with manual changes to database and import to latest hikashop. After importing of table hikashop_product_category all shop pages became broken, anywhere is shown only 1064 error (products are shown without any problem in admin). I attach error, screens and database sample. I think problem is in ordering column, so, the questions are:

1. Am I right, must be numbers in ordering column different?
2. If yes, can you help me with some query or script to change automatically these numbers, please? If needed, I can pay for this service. Products are over 8200.

Please, see attached screen and database sample:

INSERT INTO `z9sdh_hikashop_product_category` (`product_category_id`, `category_id`, `product_id`, `ordering`) VALUES
(2, 1108, 2, 2),
(1, 1108, 1, 1),
(1279344, 1012, 1271372, 1),
(1271373, 1012, 1271373, 1),
(1271374, 1012, 1271374, 1),
(1271375, 1012, 1271375, 1),
(1271376, 1012, 1271376, 1),
(1271377, 1012, 1271377, 1),
(1271378, 1012, 1271378, 1),
(1271379, 1012, 1271379, 1),
(1271380, 1012, 1271380, 1),
(1271370, 1012, 1271370, 1),
(4730, 1012, 1271371, 1),
(4731, 1028, 1271341, 1),
(4732, 1014, 1271216, 1),
(4733, 1014, 1271217, 1),
(4734, 1014, 1271218, 1),
(4735, 1014, 1271220, 1),
(4736, 1014, 1271221, 1),
(4737, 1014, 1271223, 1),
(4738, 1014, 1271224, 1),
(4739, 1015, 1271225, 1),
(4740, 1013, 1271205, 1),
(4741, 1013, 1271206, 1),
(4742, 1013, 1271207, 1),
(4743, 1015, 1271226, 1),
(4744, 1013, 1271209, 1),
(4745, 1013, 1271210, 1),
(4746, 1013, 1271211, 1),
(4747, 1013, 1271212, 1),
(4748, 1014, 1271213, 1),
(4749, 1014, 1271214, 1),
(4750, 1014, 1271215, 1),
(4751, 1014, 1271219, 1),

Attachments:
Last edit: 8 years 4 months ago by eduarddimitrov.

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

  • Posts: 12953
  • Thank you received: 1778
8 years 4 months ago #245099

Hello,

Firstly, can you use the "Check Database" button via "Hikashop->System->Configuration"

Thank you !

Last edit: 8 years 4 months ago by Mohamed Thelji.

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

  • Posts: 43
  • Thank you received: 1
8 years 4 months ago #245194

Done, I click on "Check Database" button. Message for all database tables was: OK Table "hikashop_xxxx" checked.

But nothing different happened in database and errors are still here.

Last edit: 8 years 4 months ago by eduarddimitrov.

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

  • Posts: 43
  • Thank you received: 1
8 years 4 months ago #245205

P.S. product_id is id of product.
category_id is category where is product published.
ordering - order ing of current product in category.

But what must be in database field product_category_id?

Last edit: 8 years 4 months ago by eduarddimitrov.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
8 years 4 months ago #245239

Hi,

The problem is not in the HikaShop database.
And it is not in HikaShop either.
It is in the script which created that MySQL query:

SELECT DISTINCT content.product_id AS id, content.product_name AS title, content.product_description AS text, contentR.product_modified AS date, contentR.product_created AS date_publish FROM #__hikashop_product AS content LEFT JOIN #__hikashop_product_category AS category ON category.product_id = content.product_id LEFT JOIN #__hikashop_product AS contentR ON contentR.product_id = content.product_id WHERE contentR.product_parent_id = 0 AND contentR.product_published = 1 AND ( category.category_id = 2 OR category.category_id = 3 OR category.category_id = 5 OR category.category_id = 10 OR category.category_id = 14 OR category.category_id = 18 OR category.category_id = 655 OR category.category_id = 656 OR category.category_id = 657 OR category.category_id = 658 OR category.category_id = 659 OR category.category_id = 660 OR category.category_id = 661 OR category.category_id = 662 OR category.category_id = 663 OR category.category_id = 664 OR category.category_id = 665 OR category.category_id = 666 OR category.category_id = 667 OR category.category_id = 668 OR category.category_id = 669 OR category.category_id = 671 OR category.category_id = 674 OR category.category_id = OR category.category_id = 714 OR category.category_id = 715 OR category.category_id = 716 OR category.category_id = 718 OR category.category_id = 719 OR category.category_id = 720 OR category.category_id = 721 OR category.category_id = 722 OR category.category_id = 723 OR category.category_id = 724 OR category.category_id = 725 OR category.category_id = 976 OR category.category_id = 979 OR category.category_id = 980 OR category.category_id = 981 OR category.category_id = 982 OR category.category_id = 983 OR category.category_id = 984 OR category.category_id = 985 OR category.category_id = 986 OR category.category_id = 987 OR category.category_id = 988 OR category.category_id = 989 OR category.category_id = 990 OR category.category_id = 991 OR category.category_id = 992 OR category.category_id = 993 OR category.category_id = 994 OR category.category_id = 995 OR category.category_id = 998 OR category.category_id = 999 OR category.category_id = 1000 OR category.category_id = 1001 OR category.category_id = 1002 OR category.category_id = 1003 OR category.category_id = 1004 OR category.category_id = 1005 OR category.category_id = 1006 OR category.category_id = 1007 OR category.category_id = 1009 OR category.category_id = 1010 OR category.category_id = 1012 OR category.category_id = 1013 OR category.category_id = 1014 OR category.category_id = 1015 OR category.category_id = 1016 OR category.category_id = 1017 OR category.category_id = 1018 OR category.category_id = 1019 OR category.category_id = 1020 OR category.category_id = 1024 OR category.category_id = 1025 OR category.category_id = 1026 OR category.category_id = 1027 OR category.category_id = 1028 OR category.category_id = 1029 OR category.category_id = 1032 OR category.category_id = 1033 OR category.category_id = 1034 OR category.category_id = 1035 OR category.category_id = 1037 OR category.category_id = 1038 OR category.category_id = 1039 OR category.category_id = 1040 OR category.category_id = 1041 OR category.category_id = 1042 OR category.category_id = 1043 OR category.category_id = 1044 OR category.category_id = 1045 OR category.category_id = 1047 OR category.category_id = 1048 OR category.category_id = 1050 OR category.category_id = 1051 OR category.category_id = 1052 OR category.category_id = 1053 OR category.category_id = 1054 OR category.category_id = 1055 OR category.category_id = 1056 OR category.category_id = 1057 OR category.category_id = 1058 OR category.category_id = 1059 OR category.category_id = 1060 OR category.category_id = 1061 OR category.category_id = 1062 OR category.category_id = 1063 OR category.category_id = 1064 OR category.category_id = 1065 OR category.category_id = 1066 OR category.category_id = 1067 OR category.category_id = 1068 OR category.category_id = 1077 OR category.category_id = 1078 OR category.category_id = 1080 OR category.category_id = 1081 OR category.category_id = 1082 OR category.category_id = 1083 OR category.category_id = 1084 OR category.category_id = 1085 OR category.category_id = 1087 OR category.category_id = 1089 OR category.category_id = 1090 OR category.category_id = 1091 OR category.category_id = 1092 OR category.category_id = 1093 OR category.category_id = 1094 OR category.category_id = 1095 OR category.category_id = 1096 OR category.category_id = 1097 OR category.category_id = 1098 OR category.category_id = 1099 OR category.category_id = 1100 OR category.category_id = 1101 OR category.category_id = 1102 OR category.category_id = 1103 OR category.category_id = 1108 OR category.category_id = 1110 OR category.category_id = 1111 OR category.category_id = 1112 OR category.category_id = 1113 OR category.category_id = 1114 OR category.category_id = 1116 OR category.category_id = 1117 OR category.category_id = 1118 OR category.category_id = 1119 OR category.category_id = 1120 OR category.category_id = 1121 OR category.category_id = 1127 OR category.category_id = 1135 OR category.category_id = 1136) ORDER BY contentR.product_created DESC LIMIT 0,8;
As MySQL says, there is an id missing in at least one of the conditions of the query:
OR category.category_id = OR category.category_id = 714
As that MySQL query isn't in the code of HikaShop, I suppose that it comes from a third party plugin or a custom script of yours.
There, you need to cast the ids to integers before adding the conditions on them in the query and the query will then work.

product_category_id is filled automatically by MySQL since its an auto_increment. It's the id of the link between a category and a product. You should not have to fill it.

The following user(s) said Thank You: eduarddimitrov

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

  • Posts: 43
  • Thank you received: 1
8 years 4 months ago #245274

@nicolas, problem is not with custom script, is with any template. Initially we use Gavick template - storefront. Problem was on homepage, error was shown from News Show Pro GK5 module. We switch them off. But exact error was shown on all pages of categories - on any menus point to product categegory from hikashop.

You can say this comes from Gavick template :) Yes, maybe it's true. I can't say problem is in Hikashop because as I say in first post, problem is due on our work - "migration of huge online store from K2 to Hikashop with manual changes to database".

We solve problem. And the problem was simple: Four products was published in non existing categories. We change categories in database and site start working well.

But I think you can help us with simple answers... until today I got no answer for questions like "what must be in database field product_category_id" and "must be numbers in ordering column of hikashop_product_category table different".

Will be also good to test latest Hikashop version for exact thing - publish some product in some category and delete this category. I am sure you will got the same errors.

Last edit: 8 years 4 months ago by eduarddimitrov.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 4 months ago #245296

Hi,

There is no problem with that if the query is built to handle it.
You do not need to load the category table if you do not want to get his data ; just use the "product_category" table.
And please use " IN (...) " instead of a lof or " = .. OR = ... ". Thus you will be able to list all the IDs in an Array and perform a JArrayHelper::toInteger in order to be sure that you do not have an invalid data in the list.

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.
The following user(s) said Thank You: eduarddimitrov

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

  • Posts: 43
  • Thank you received: 1
8 years 4 months ago #245352

Thank you, Jerome,

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

Time to create page: 0.078 seconds
Powered by Kunena Forum