Hello,
Maybe you can try another way (and a most simple !), if your goal is only to have specific url per category (and sub-category) for this in your HikaShop Configuration, go to Products dropdown => Categories, then click to edit your categories and sub-categories and enter a specific alias to your category.
And in HikaShop Configuration, go to Features tab, and in SEF url options, define your required SEF options (Category, Product SEF name) and active the "Alias automatic filling" option, in order to fill SEF url with your deinfe product & category alias.
Hope this will help you to achieved your needs.
Regards