Selecting product in order editing

  • Posts: 19
  • Thank you received: 2
  • Hikaserial Standard Hikashop Business
2 years 7 months ago #335889

-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.28
-- PHP version -- : 7.4.22

Hi,

we have problem when searching for product in namebox (selection.php), it searches only in main products, not variants (eg product code). I tried to identify the problem and found these:

  • when it finds no product (looking for search string by ajax call of getTree) it returns 500 error, reason is that on the line 4261 of the class product.php you create wrong SQL query - the $lookup_categories is empty
  • the reason why $lookup_categories is empty is on the line 4236 where you INNER JOIN product_categories but I suppose that variants does not have connection to product_categories, only main product
  • so even if you repair the wrong SQL query by checking for empty lookup_categories it still returns empty result eventhough we are searching for existing variant product_code

Am I right? If so, is it possible to repair it?

Thanks, Jan

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
2 years 7 months ago #335920

Hi,

Mmm. I'm not able to reproduce the problem on my end and I don't see why the inner join would be a problem either.
The MySQL query does a join between hikashop_product.product_id (p) and hikashop_product.product_parent_id (v) and then a join between hikashop_product.product_id (p) and hikashop_product_category.product_id (pc).
So before applying the where conditions you get in the MySQL memory a table which is a combination of these three tables (+ others we don't care about here), so that you'll get one row for each variant (or one for the product if he doesn't have any). Then, MySQL will apply the conditions and we made is so that it will search in both p.product_code and p.product_name but also v.product_code and v.product_name
So while it's true that due to the inner join, he won't be able to match with the name/code of the variants in p.product_code and p.product_name (since the entries for the variants in p will be removed by the inner join on pc), it will be able to in v.product_name and v.product_code (since the entries for the variants in v will still be there as they first join to p before joining to pc through p).

However, I am able to reproduce the 500 error locally. For that I just need to enter some text which isn't either in a product name/code, nor in a variant name/code, nor in a category name. In that case, $lookup_categories will indeed be empty and the MySQL query will fail.

So I will add some modifications for the next release to remove the 500 error and have instead a soft fail so that no error happen.

Thus, I conclude that you must have been searching for something which isn't set in a variant name/code to get that 500 error. Could you double check ?

Note also that when a variant matches, the + of the product itself is not opened. So it's up to you to open it and select the variant.
That's because the variant support was added at a later point, and it's kind of a patch on the original system and thus it doesn't really support openning the main product and filtering out the non matching variants. That would require quite a bit of modifications to be able to support that and we deemed it as not worth it.

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

  • Posts: 19
  • Thank you received: 2
  • Hikaserial Standard Hikashop Business
2 years 1 week ago #340859

Hi,

thanks. It took me some to time to update but evidently it is working now.

Jan

The following user(s) said Thank You: nicolas

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

Time to create page: 0.065 seconds
Powered by Kunena Forum