Importing a category tree when several categories share the same name

  • Posts: 68
  • Thank you received: 3
  • Hikamarket Multivendor Hikashop Business
2 weeks 6 days ago #373193

-- HikaShop version -- : 6.5.2
-- Joomla version -- : 6;1.3
-- PHP version -- : 8.3

Hi
We use HikaShop on Joomla (FaLang: ru, en, ua, ge). Our catalog is a tree where leaf categories often have the same display name under different parents. Example:

Judaica → Hamsa
Christianity → Hamsa
(later) Brand A → Hand cream / Brand B → Hand cream
The names on the storefront must stay identical. Renaming leaves (“Hamsa Judaica”, “Hand cream 1”) is not acceptable.

What we tried

Product import (Products → Import) with parent_category + categories, and “Create automatically missing categories” enabled.
HikaShop looks up categories by name and takes the first match. The second “Hamsa” is not created; products from both branches land in one category. parent_category does not disambiguate an existing category.

Putting only the leaf name in categories (as in a HikaShop product export) — same result.

Docs say the categories column can be IDs or namekeys. That works for assigning products, but only after the two “Hamsa” categories already exist. Product import does not seem able to create two categories with the same category_name and different namekeys.

Nicolas wrote on the forum that aliases cannot be used for this, and that category IDs should be used instead.

Question

What is the supported way to create and update such a tree automatically (CSV, mass action, or another built-in tool), so that:

display names may repeat;
each category has a stable unique key (namekey or ID);
later product imports can attach products by that key, not by name?
Is there a category-only import (not the product importer) that accepts category_name + category_namekey + parent?
Or can product import create a missing category by namekey while keeping a separate display name?

We would rather not maintain a custom PHP script or import #__hikashop_category by hand. If the product CSV cannot do this, please confirm that, and tell us the official workflow you recommend.

Thank you

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

  • Posts: 86183
  • Thank you received: 14218
  • MODERATOR
2 weeks 6 days ago #373195

Hi,

Yes, there is a supported way to do this now, and it is new in HikaShop 6.6.0, which we released two days ago, so it is not on your 6.5.2 yet.

Under Products > Categories, you now have an "Import" button which opens a wizard taking a CSV or an XML file, or the content of a CSV pasted in the page. It is made exactly for the case you describe:

- a row is matched with an existing category by its id, then by its namekey, then by its name under the parent of that row, so a second "Hamsa" under a different parent is created instead of the first one being reused;
- you can give the namekey of each category yourself in a category_namekey column, so every category has the stable unique key you are after;
- the parent of a row is given in a category_parent_id column, which accepts an id, a namekey or a name, and the rows can be in any order: a row whose parent is further down the file waits for it, so a whole tree can be described in one file.

So your tree would be a file like this one:

category_name,category_namekey,category_parent_id
Hamsa,jud-hamsa,judaica
Hamsa,chr-hamsa,christianity
Hand cream,brand-a-hand-cream,brand-a
Hand cream,brand-b-hand-cream,brand-b
Brand A,brand-a,
Brand B,brand-b,

I ran that file here on a 6.6.0 and it gives two "Hamsa" and two "Hand cream", each under its own parent, each with the namekey of the file, and the tree rebuilt.

Once the tree is there, your product import can attach the products by that key: put the namekey in the "categories" column of your product CSV instead of the name, since HikaShop looks a category up by namekey before looking it up by name. The display names can then repeat as much as you like, and a later import updates the right branch. The same file can be loaded again later to update the descriptions, the SEO texts, the access levels or the images of the categories, and a mass action on the categories can export them in that format to start from.

One thing on top of that, since you also reported it: in the product import, when parent_category is given and no category of that name exists yet under it, HikaShop attaches the products to the first category carrying that name instead of creating a new one under the parent you gave. That is a bug on our side, I reproduced it here, and it is fixed. The fix is already in the 6.6.0 package, so updating to i, by downloading it from your account on our website and installing it on yours gives you both the category import and that correction. With the fix, your original approach works as you expected as well, though I would still recommend the category import plus the namekeys, since a name is not a reliable key for a catalogue like yours and it can handle all the category columns, not just the main ones.

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

  • Posts: 68
  • Thank you received: 3
  • Hikamarket Multivendor Hikashop Business
2 weeks 5 days ago #373205

Hi Nicolas!
thank you.
We are imported new categories+subcategory tree and after this we are imported products.
Up to this step - all is perfect.
But then I try to enter to any new product - I get 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 'AND hk_parent.category_right <= ORDER BY hk_parent.category_left' at line 1

You can try here: made-in-holyland.com/ru/religiya/khristi...nastennoe-ukrashenie .
End Breadcrumb have this structure:
Религия Христианство: Настенное украшение product category Христианство.

The site has four languages: Russian (the main language), English, Ukrainian, and Georgian.
It's strange that the error only appears in Russian.
And yes, we use fabola for joomla,.
Any solution?
thank you.

Last edit: 2 weeks 5 days ago by designer71.

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

  • Posts: 68
  • Thank you received: 3
  • Hikamarket Multivendor Hikashop Business
2 weeks 5 days ago #373206

This attachment is hidden for guests.
Please log in or register to see it.
This attachment is hidden for guests.
Please log in or register to see it.
Database error after category CSV import (6.6.0) + product import by namekey

Hello,

We updated to HikaShop 6.6.0 and used the new Products → Categories → Import, then Products → Import. The category tree and products appeared, but the shop now reports a database problem when working with products.

What we imported

Categories: CSV, UTF-8 with BOM, comma-separated, quoted fields:
category_name,category_namekey,category_parent_id
category_name — display name (may repeat, e.g. two “Hamsa”, two “Keychains”).
category_namekey — our stable keys, hlb_{id}.
category_parent_id — parent namekey (empty for top-level).
Products: our usual product CSV (semicolon, UTF-8 BOM). Column categories contains the namekey (hlb_12), not the display name. “Create missing categories” was off. Update by product_code was on.
We had previously imported the same catalog with the old product importer (duplicate leaf names all landed under Judaica). Those products and that tree were deleted before this 6.6.0 import.

Possible clue from our side

One earlier category export mistakenly had the literal string None in category_namekey / category_parent_id for several rows (Judaica, Christianity, Magnets, and children pointing at parent None). If that file was imported even once, several rows would share the same namekey None, which should violate uniqueness on #__hikashop_category.category_namekey.

The file that was meant to be used after that had real keys only (hlb_6, hlb_15, …), no None.

What we need

The exact error message, and if possible the SQL / stack trace (PHP error, SQLSTATE).
Whether #__hikashop_category has duplicate category_namekey values, or broken nested-set columns (category_left / category_right).
Whether this is a known issue in 6.6.0 after Categories → Import followed by a product import that assigns categories by namekey.
We can send both CSV files if useful.

Thank you,

This message has attachments files.
Please log in or register to see it.

Last edit: 2 weeks 5 days ago by designer71.

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

  • Posts: 86183
  • Thank you received: 14218
  • MODERATOR
2 weeks 5 days ago #373210

Hi,

Thank you for the details, they were enough to find it, and it has nothing to do with the import: your categories and your products are fine.

That error comes from the breadcrumb of the product page. The menu item your product pages are opened from is a products listing, and its "Main category" setting names several categories. That setting accepts several categories since 6.6.0, while the product page was still reading it as a single one to cut the breadcrumb at, which is what produced the broken query. That also explains why only one of your languages is affected: the menu items of the others name a single category, or none.

I've added a patch for this on our end. Download again the install package of the 6.6.0 on our website and install it on your website in order to get it.

On the two things you were wondering about, so that they don't stay open: several categories cannot share a namekey, the column is unique in the table and the import updates the category already carrying a namekey rather than adding a second one, so the file with "None" in it left one category at most. And the tree columns are rebuilt at the end of every category import, so the tree is not what broke here either.

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

  • Posts: 68
  • Thank you received: 3
  • Hikamarket Multivendor Hikashop Business
2 weeks 4 days ago #373216

Hi Nicolas,
thank you.
Now products is ok.
But breadcrumbs displayed anything wrong on all languages:

Souvenirs from the Holy Land | Judaica | Jewish symbolism | product category | Judaica

For example:
made-in-holyland.com/en/religiya/iudaika/jewish-symbolism
made-in-holyland.com/ru/religiya/khristi...nastennoe-ukrashenie
made-in-holyland.com/ua/suveniry-so-svya...hristianstvo/breloki

and other..,,,

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

  • Posts: 86183
  • Thank you received: 14218
  • MODERATOR
2 weeks 4 days ago #373218

Hi,

Thank you for your feedback on this too. This is another issue related to the changes we made in the 6.6.0 in order to support several categories in the main category setting of menu items.
I've made several patches on our end. I've reproduced the issue to the best of my abilities and confirmed the patches fix the problem.
Download again the install package of the 6.6.0 on our website and install it on your website in order to get them.
The breadcrumbs should then display properly.

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

  • Posts: 68
  • Thank you received: 3
  • Hikamarket Multivendor Hikashop Business
2 weeks 4 days ago #373233

Perfect!
thank you!

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

Time to create page: 0.071 seconds
Powered by Kunena Forum