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

#   Creating products programmatically / miscellaneous questions

##

- **[DomB22](/forum/user/82577-domb22 "View DomB22's Profile")**
- [![DomB22's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/82577-domb22 "View DomB22's Profile") Topic Author
- [ Offline](/forum/user/82577-domb22)

Less More

- Posts: 9
- Thank you received: 1
-
-

2 years 4 months ago -  2 years 4 months ago [\#362023](#362023) by [DomB22](/forum/user/82577-domb22 "View DomB22's Profile")  *[Creating products programmatically / miscellaneous questions](/forum/31-development/908380-creating-products-programmatically-miscellaneous-questions#362023 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 4.4.5  I'm writing a plugin which creates products. I've managed to add categories, various prices levels, custom fields and at this time I still have two questions : - is it possible to generate automatically a product&#95;alias upon creation? - how is it possible to add multilingual versions (in my case en-GB and fr-FR) of the half-dozen translatable product fields? By the way, is it possible to make a 'text' custom field multilingual?")* was created by *[DomB22](/forum/user/82577-domb22 "View DomB22's Profile")*

-- HikaShop version -- : 5.1.0
-- Joomla version -- : 4.4.5

I'm writing a plugin which creates products. I've managed to add categories, various prices levels, custom fields and at this time I still have two questions :
- is it possible to generate automatically a product_alias upon creation?
- how is it possible to add multilingual versions (in my case en-GB and fr-FR) of the half-dozen translatable product fields? By the way, is it possible to make a 'text' custom field multilingual?

Last edit: 2 years 4 months ago by [DomB22](/forum/user/82577-domb22 "View DomB22's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50LzkwODM4MC1jcmVhdGluZy1wcm9kdWN0cy1wcm9ncmFtbWF0aWNhbGx5LW1pc2NlbGxhbmVvdXMtcXVlc3Rpb25zP3RtcGw9bWFya2Rvd24=) 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: 86584
- Thank you received: 14325
-
-

2 years 4 months ago [\#362029](#362029) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Creating products programmatically / miscellaneous questions](/forum/31-development/908380-creating-products-programmatically-miscellaneous-questions#362029 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 4.4.5  I'm writing a plugin which creates products. I've managed to add categories, various prices levels, custom fields and at this time I still have two questions : - is it possible to generate automatically a product&#95;alias upon creation? - how is it possible to add multilingual versions (in my case en-GB and fr-FR) of the half-dozen translatable product fields? By the way, is it possible to make a 'text' custom field multilingual?")*

Hi,

1. Yes. You can use such code to generate the alias from the product name automatically: Code:

// supposing you have your product data in $product $productClass = hikashop_get('class.product'); $productClass-&gt;addAlias($product); $product-&gt;product_alias = $product-&gt;alias; unset($product-&gt;alias); $productClass-&gt;save($product);

2. If you want to programmatically add translations to products, you can do like this: Code:

$translations = array( 'product_name' =&gt; array( 1 =&gt; 'product name in english', 2 =&gt; 'nom du produit en français', ), 'product_description' =&gt; array( 1 =&gt; 'product description in english', 2 =&gt; 'description du produit en français', ), ); $translationHelper = hikashop_get('helper.translation'); $translationHelper-&gt;handleTranslations('product', $product-&gt;product_id, $product, 'hikashop_', $translations);

This assumes that the id of the en-GB language in your Joomla is 1 and the id of the fr-FR language in your Joomla is 2.
You want to look at the lang_id column of the languages table of Joomla in the database in order to know these ids. The loadLanguage method of $translationHelper will return an array of objects from this table with the id and the code for each language.

3. If you want a custom product field to be multilingual, you need to edit the settings of the custom field in the menu Display&gt;Custom fields and turn on the "Translatable" setting. The custom field will then be automatically added to the translation popup of each product.

The following user(s) said Thank You: [DomB22](/forum/user/82577-domb22 "View DomB22's Profile")

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

- **[DomB22](/forum/user/82577-domb22 "View DomB22's Profile")**
- [![DomB22's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/82577-domb22 "View DomB22's Profile") Topic Author
- [ Offline](/forum/user/82577-domb22)

Less More

- Posts: 9
- Thank you received: 1
-
-

2 years 4 months ago [\#362171](#362171) by [DomB22](/forum/user/82577-domb22 "View DomB22's Profile")  Replied by *[DomB22](/forum/user/82577-domb22 "View DomB22's Profile")* on topic *[Creating products programmatically / miscellaneous questions](/forum/31-development/908380-creating-products-programmatically-miscellaneous-questions#362171 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 4.4.5  I'm writing a plugin which creates products. I've managed to add categories, various prices levels, custom fields and at this time I still have two questions : - is it possible to generate automatically a product&#95;alias upon creation? - how is it possible to add multilingual versions (in my case en-GB and fr-FR) of the half-dozen translatable product fields? By the way, is it possible to make a 'text' custom field multilingual?")*

Following your answers it works fine, thank you for the great support Nicolas.

The following user(s) said Thank You: [Philip](/forum/user/34318-philip "View Philip's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50LzkwODM4MC1jcmVhdGluZy1wcm9kdWN0cy1wcm9ncmFtbWF0aWNhbGx5LW1pc2NlbGxhbmVvdXMtcXVlc3Rpb25zP3RtcGw9bWFya2Rvd24=) 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.050 seconds

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