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

#   Query dynamic id

##

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile") Topic Author
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

8 years 5 months ago [\#293507](#293507) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  *[Query dynamic id](/forum/31-development/894893-query-dynamic-id#293507 "Hi,  I do have such query which displays characteristic values of the product in product listing:  Now the issue that i have 2 size characteristics. One for clothes and second for shoes with different id's. Is there a way to have dynamic characteristic&#95;parent&#95;id? I have spent some time but only what i could think is to set id based on category id which works well but it gives other issues for module which display random products...  Could Anyone with better knowledge give some hint please?  Thanks")* was created by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")*

Hi,

I do have such query which displays characteristic values of the product in product listing:
Code:

&lt;?php $database = JFactory::getDBO(); $query="SELECT group_concat(product_id) as product_ids from &#96;ozi8g_hikashop_product&#96; WHERE ( product_parent_id=".$this-&gt;row-&gt;product_id.") and product_quantity&gt;0 and product_published&gt;0 "; $database-&gt;setQuery($query); $parent_product_ids=$database-&gt;loadResult(); $this-&gt;row-&gt;product_id=$parent_product_ids; $cat_id = '21'; $query = 'select * from ozi8g_hikashop_variant as v left join ozi8g_hikashop_characteristic as c on v.variant_characteristic_id=c.characteristic_id where characteristic_parent_id='.$cat_id.' and variant_product_id in ('.$parent_product_ids.') GROUP BY characteristic_id ORDER BY &#96;c&#96;.&#96;characteristic_ordering&#96; ASC'; $database-&gt;setQuery($query); $rows = $database-&gt;loadObjectList(); foreach($rows as $row){ echo '&lt;span class="tz-pchars"&gt;'.$row-&gt;characteristic_value.'&lt;/span&gt;'; } ?&gt;

Now the issue that i have 2 size characteristics. One for clothes and second for shoes with different id's. Is there a way to have dynamic characteristic_parent_id? I have spent some time but only what i could think is to set id based on category id which works well but it gives other issues for module which display random products...

Could Anyone with better knowledge give some hint please?

Thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NDg5My1xdWVyeS1keW5hbWljLWlkP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

8 years 5 months ago [\#293528](#293528) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Query dynamic id](/forum/31-development/894893-query-dynamic-id#293528 "Hi,  I do have such query which displays characteristic values of the product in product listing:  Now the issue that i have 2 size characteristics. One for clothes and second for shoes with different id's. Is there a way to have dynamic characteristic&#95;parent&#95;id? I have spent some time but only what i could think is to set id based on category id which works well but it gives other issues for module which display random products...  Could Anyone with better knowledge give some hint please?  Thanks")*

Hi,

It depends... ![:)](/media/kunena/emoticons/3.png ":)")
If you have no other characteristics in your products, then simply remove "characteristic_parent_id='.$cat_id.' and" so that it will pick the values of all the characteristics of the product, regardless of the characteristic used in the product.
If that's not the case, then you can create a custom product field via the menu Display&gt;Custom fields in order to fill the characteristic id for each product, and then use $this-&gt;row-&gt;XXX instead of $cat_id (where XXX is the column name of the custom field) so that it can be different for different products even in the same listing.

The following user(s) said Thank You: [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")

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

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile") Topic Author
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

8 years 5 months ago [\#293641](#293641) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  Replied by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")* on topic *[Query dynamic id](/forum/31-development/894893-query-dynamic-id#293641 "Hi,  I do have such query which displays characteristic values of the product in product listing:  Now the issue that i have 2 size characteristics. One for clothes and second for shoes with different id's. Is there a way to have dynamic characteristic&#95;parent&#95;id? I have spent some time but only what i could think is to set id based on category id which works well but it gives other issues for module which display random products...  Could Anyone with better knowledge give some hint please?  Thanks")*

Hi,

So your hint Nicolas was really awesome. ![;)](/media/kunena/emoticons/24.png ";)") My products have 2 characteristics so first option won't work. For the second one, i dont want to enter some id for every product as it will take time. What i did, i added NOT Operator and changed "where characteristic_parent_id='.$cat_id.' " to "WHERE NOT characteristic_parent_id='.$cat_id.' " and entered id which i dont want to show. Now all works perfect. I hope this will help someone in the future.

Thanks for support Nicolas.

Have a great day

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

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

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