[Skip to main content](#vessel-content)

#   Function to generate a product alias

##

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

9 years 10 months ago [\#258070](#258070) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  *[Function to generate a product alias](/forum/32-content-creation/888011-function-to-generate-a-product-alias#258070 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.4 -- Browser(s) name and version -- : Any  I'm building a product importer from a third party DB to Hikashop,  I need to know what function or procedures is required to generate a product alias the way HikaShop does.  Can I call it from my own code built in a separate component?  Thanks in advance.  -- Víctor")* was created by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")*

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.4
-- Browser(s) name and version -- : Any

I'm building a product importer from a third party DB to Hikashop,

I need to know what function or procedures is required to generate a product alias the way HikaShop does.

Can I call it from my own code built in a separate component?

Thanks in advance.

-- Víctor

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NvbnRlbnQtY3JlYXRpb24vODg4MDExLWZ1bmN0aW9uLXRvLWdlbmVyYXRlLWEtcHJvZHVjdC1hbGlhcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86357
- Thank you received: 14289
-
-

9 years 10 months ago [\#258073](#258073) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Function to generate a product alias](/forum/32-content-creation/888011-function-to-generate-a-product-alias#258073 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.4 -- Browser(s) name and version -- : Any  I'm building a product importer from a third party DB to Hikashop,  I need to know what function or procedures is required to generate a product alias the way HikaShop does.  Can I call it from my own code built in a separate component?  Thanks in advance.  -- Víctor")*

Hi,

Yes.
You can do like that: Code:

include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_hikashop'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php'); $class = hikashop_get('class.product'); $class-&gt;addAlias($productDataObject); echo $productDataObject-&gt;alias;

The following user(s) said Thank You: [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NvbnRlbnQtY3JlYXRpb24vODg4MDExLWZ1bmN0aW9uLXRvLWdlbmVyYXRlLWEtcHJvZHVjdC1hbGlhcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

9 years 10 months ago [\#258102](#258102) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Function to generate a product alias](/forum/32-content-creation/888011-function-to-generate-a-product-alias#258102 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.4 -- Browser(s) name and version -- : Any  I'm building a product importer from a third party DB to Hikashop,  I need to know what function or procedures is required to generate a product alias the way HikaShop does.  Can I call it from my own code built in a separate component?  Thanks in advance.  -- Víctor")*

Thank you Nicolas,

I forgot to mention that in my import process from the third party DB there is a potential risk that some products share exactly the same name although the "product code" is always unique, so to avoid potential alias conflicts i would like to add the product_code at the end of the alias as a standard rule. Also, many users / clients will identify first the product by its reference (product_code) than by its name, so in my opinion this is not breaking the SEF logic as many people will search at google by product code.

Do you see any inconvenience in this practice?

How can we add this in a stable way in our system so it does not reset for each hikashop update?

Thank you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NvbnRlbnQtY3JlYXRpb24vODg4MDExLWZ1bmN0aW9uLXRvLWdlbmVyYXRlLWEtcHJvZHVjdC1hbGlhcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86357
- Thank you received: 14289
-
-

9 years 10 months ago [\#258113](#258113) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Function to generate a product alias](/forum/32-content-creation/888011-function-to-generate-a-product-alias#258113 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.4 -- Browser(s) name and version -- : Any  I'm building a product importer from a third party DB to Hikashop,  I need to know what function or procedures is required to generate a product alias the way HikaShop does.  Can I call it from my own code built in a separate component?  Thanks in advance.  -- Víctor")*

Hi,

1. I don't see any problem with that.

2. I don't understand what you mean ? You said in your first message that this code was to be added to the import process in your custom component. Why would HikaShop updates change the products alias or the code of your component ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NvbnRlbnQtY3JlYXRpb24vODg4MDExLWZ1bmN0aW9uLXRvLWdlbmVyYXRlLWEtcHJvZHVjdC1hbGlhcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

9 years 10 months ago [\#258161](#258161) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Function to generate a product alias](/forum/32-content-creation/888011-function-to-generate-a-product-alias#258161 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.4 -- Browser(s) name and version -- : Any  I'm building a product importer from a third party DB to Hikashop,  I need to know what function or procedures is required to generate a product alias the way HikaShop does.  Can I call it from my own code built in a separate component?  Thanks in advance.  -- Víctor")*

About point 2.

Sorry for my bad explanation:

My idea is that I would change the HikaShop function to add this product_code in the alias both when the product is imported by my code and when it is created directly in the system so I keep everywhere the same alias scheme.

So, if then I update HikaShop I would potentially loose this alias building "tweak" as I don't think this is an overridable part of the script.

right?

So the question is:

Is there a way to circumvent this, and tell hikashop always to do this with alias? Like maybe rebuilding the alias all the time with an OnBeforeCreate and nBeforeUpdate trigger?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NvbnRlbnQtY3JlYXRpb24vODg4MDExLWZ1bmN0aW9uLXRvLWdlbmVyYXRlLWEtcHJvZHVjdC1hbGlhcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86357
- Thank you received: 14289
-
-

9 years 10 months ago [\#258169](#258169) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Function to generate a product alias](/forum/32-content-creation/888011-function-to-generate-a-product-alias#258169 "-- HikaShop version -- : 2.6.4 -- Joomla version -- : 3.6.4 -- Browser(s) name and version -- : Any  I'm building a product importer from a third party DB to Hikashop,  I need to know what function or procedures is required to generate a product alias the way HikaShop does.  Can I call it from my own code built in a separate component?  Thanks in advance.  -- Víctor")*

Hi,

Exactly, just implement the onBeforeProductCreate and onBeforeProductUpdate triggers in a plugin of the group HikaShop and generate the alias yourself the way you want it. That way, HikaShop will use it automatically.

The following user(s) said Thank You: [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NvbnRlbnQtY3JlYXRpb24vODg4MDExLWZ1bmN0aW9uLXRvLWdlbmVyYXRlLWEtcHJvZHVjdC1hbGlhcz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.057 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
