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

#   populate variants in product object

##

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

Less More

- Posts: 12
- Thank you received: 0
-
-

12 years 11 months ago [\#133275](#133275) by [vu-ittc](/forum/user/28502-vu-ittc "View vu-ittc's Profile")  *[populate variants in product object](/forum/26-product-category-display/863771-populate-variants-in-product-object#133275 "code taken from your &quot;dev&quot; section:  $prodClass = hikashop&#95;get('class.product'); $prod=$prodClass-&gt;get($id);  the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?")* was created by *[vu-ittc](/forum/user/28502-vu-ittc "View vu-ittc's Profile")*

code taken from your "dev" section:

$prodClass = hikashop_get('class.product');
$prod=$prodClass-&gt;get($id);

the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?

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

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

12 years 11 months ago [\#133290](#133290) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[populate variants in product object](/forum/26-product-category-display/863771-populate-variants-in-product-object#133290 "code taken from your &quot;dev&quot; section:  $prodClass = hikashop&#95;get('class.product'); $prod=$prodClass-&gt;get($id);  the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?")*

Hi,
Note that you'll also be able to do it like this : Code:

$this-&gt;database = JFactory::getDBO(); $query='SELECT * FROM '.hikashop_table('product').' WHERE product_parent_id ='.$YOURPRODUCTID; $this-&gt;database-&gt;setQuery($query); $variants = $this-&gt;database-&gt;loadObjectList();

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

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

Less More

- Posts: 12
- Thank you received: 0
-
-

12 years 10 months ago [\#135708](#135708) by [vu-ittc](/forum/user/28502-vu-ittc "View vu-ittc's Profile")  Replied by *[vu-ittc](/forum/user/28502-vu-ittc "View vu-ittc's Profile")* on topic *[populate variants in product object](/forum/26-product-category-display/863771-populate-variants-in-product-object#135708 "code taken from your &quot;dev&quot; section:  $prodClass = hikashop&#95;get('class.product'); $prod=$prodClass-&gt;get($id);  the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?")*

Hi,

thanks, however the product doesn't have prices and taxes arrays included, so it returns incorrect prices, is there a way to do it by using hikashop framework?

Link - [ parduotuve.joomlatvs.lt/joomla/](http://parduotuve.joomlatvs.lt/joomla/)

Regards,
Arminas

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

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

12 years 10 months ago -  12 years 10 months ago [\#135719](#135719) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[populate variants in product object](/forum/26-product-category-display/863771-populate-variants-in-product-object#135719 "code taken from your &quot;dev&quot; section:  $prodClass = hikashop&#95;get('class.product'); $prod=$prodClass-&gt;get($id);  the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?")*

Hi,
the problem is coming from the fact that the price is in the "hikashop_price" table, this kind of code will probably do the job : Code:

$this-&gt;database = JFactory::getDBO(); $query='SELECT * FROM '.hikashop_table('product').' AS product LEFT JOIN '.hikashop_table('price').' AS price ON product.product_id=price.price_product_id WHERE product.product_id = '. $this-&gt;element-&gt;product_id .' GROUP BY product.product_id ORDER BY price.price_min_quantity ASC'; $this-&gt;database-&gt;setQuery($query); $product = $this-&gt;database-&gt;loadObjectList();

Last edit: 12 years 10 months ago by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile").

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

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

Less More

- Posts: 12
- Thank you received: 0
-
-

12 years 10 months ago [\#135728](#135728) by [vu-ittc](/forum/user/28502-vu-ittc "View vu-ittc's Profile")  Replied by *[vu-ittc](/forum/user/28502-vu-ittc "View vu-ittc's Profile")* on topic *[populate variants in product object](/forum/26-product-category-display/863771-populate-variants-in-product-object#135728 "code taken from your &quot;dev&quot; section:  $prodClass = hikashop&#95;get('class.product'); $prod=$prodClass-&gt;get($id);  the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?")*

ok, better, now i just need the taxes and the price_with_tax in this object, how do i do that?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NjM3NzEtcG9wdWxhdGUtdmFyaWFudHMtaW4tcHJvZHVjdC1vYmplY3Q/dG1wbD1tYXJrZG93bg==) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86293
- Thank you received: 14272
-
-

12 years 10 months ago [\#135776](#135776) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[populate variants in product object](/forum/26-product-category-display/863771-populate-variants-in-product-object#135776 "code taken from your &quot;dev&quot; section:  $prodClass = hikashop&#95;get('class.product'); $prod=$prodClass-&gt;get($id);  the resulting object doesn't contain any information about product variants, like it should, according to object reference provided on your website, the class methods are too abstract and there is no method suitable for extracting this data (at least i failed to found one). how can i get product variants (in the way they are displayed on your product object reference page) by product id?")*

You need to do something like that: Code:

$currencyClass = hikashop_get('class.currency'); foreach($product as $k =&gt; $v){ $product[$k]-&gt;price_with_tax = $currencyClass-&gt;getTaxedPrice($v,hikashop_getZone(),$v-&gt;product_tax_id); $product[$k]-&gt;taxes = $currencyClass-&gt;taxRates; }

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

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

[](#top)
