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

#   Create full product with variants in php

##

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

Less More

- Posts: 71
- Thank you received: 1
-
-

10 years 2 months ago [\#247921](#247921) by [RG](/forum/user/39276-rg "View RG's Profile")  *[Create full product with variants in php](/forum/31-development/886054-create-full-product-with-variants-in-php#247921 "-- HikaShop version -- : 3.5 -- Joomla version -- : 3.6.2 -- PHP version -- : 5.5.2  Hey,  Can you provide some example code where you create a product and a variants with specific from php code?  Thanks,  RG")* was created by *[RG](/forum/user/39276-rg "View RG's Profile")*

-- HikaShop version -- : 3.5
-- Joomla version -- : 3.6.2
-- PHP version -- : 5.5.2

Hey,

Can you provide some example code where you create a product and a variants with specific from php code?

Thanks,

RG

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26400
- Thank you received: 4079
-
- [](http://obsi.dev)
-

10 years 2 months ago [\#247925](#247925) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Create full product with variants in php](/forum/31-development/886054-create-full-product-with-variants-in-php#247925 "-- HikaShop version -- : 3.5 -- Joomla version -- : 3.6.2 -- PHP version -- : 5.5.2  Hey,  Can you provide some example code where you create a product and a variants with specific from php code?  Thanks,  RG")*

Hi,

Here some code to create a product : Code:

$product = new stdClass(); $product-&gt;product_code = 'my product code'; $product-&gt;product_quantity = -1; $productClass = hikashop_get('class.product'); $productClass-&gt;save($product);

For the variant part, it is far more complicated and I can't provide you any example code ; the easier would be to read directly the HikaShop source code for the product class.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

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

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