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

#   Récupérer le nom des champs perso

##

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

Less More

- Posts: 2697
- Thank you received: 74
-
-

5 months 8 hours ago -  5 months 3 hours ago [\#372211](#372211) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  *[Récupérer le nom des champs perso](/forum/5-support-en-francais-french-support-/910585-recuperer-le-nom-des-champs-perso#372211 "-- HikaShop version -- : 6.5 -- Joomla version -- : 6.1 -- PHP version -- : 8.4  Bonjour Dans product/listing&#95;div.php  Il load listing&#95;img&#95;title.php  Et je ne récupère rien Je ne veux pas la valeur qui est stockée dans le champ perso de la db mais bien le libellé badge&#95;new = nouveauté  Comment puis-je récupérer le libellé ?  Merci")* was created by *[erickb](/forum/user/4069-erickb "View erickb's Profile")*

-- HikaShop version -- : 6.5
-- Joomla version -- : 6.1
-- PHP version -- : 8.4

Bonjour
Dans product/listing_div.php
Code:

$fieldClass = hikashop_get("class.field"); $this-&gt;badgeField = $fieldClass-&gt;getField("product_badges"); $this-&gt;sizeField = $fieldClass-&gt;getField("product_size_values");

Il load listing_img_title.php
Code:

$badgesHtml = ""; if(!empty($this-&gt;badgeField) &amp;&amp; !empty($this-&gt;row-&gt;product_badges)) { $this-&gt;badgeField-&gt;currentElement = $this-&gt;row; $badgesHtml = $this-&gt;fieldsClass-&gt;show( $this-&gt;badgeField, $this-&gt;row-&gt;product_badges ); }

Et je ne récupère rien
Je ne veux pas la valeur qui est stockée dans le champ perso de la db mais bien le libellé
badge_new = nouveauté

Comment puis-je récupérer le libellé ?

Merci

Last edit: 5 months 3 hours ago by [erickb](/forum/user/4069-erickb "View erickb's Profile").

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

5 months 4 hours ago [\#372212](#372212) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Récupérer le nom des champs perso](/forum/5-support-en-francais-french-support-/910585-recuperer-le-nom-des-champs-perso#372212 "-- HikaShop version -- : 6.5 -- Joomla version -- : 6.1 -- PHP version -- : 8.4  Bonjour Dans product/listing&#95;div.php  Il load listing&#95;img&#95;title.php  Et je ne récupère rien Je ne veux pas la valeur qui est stockée dans le champ perso de la db mais bien le libellé badge&#95;new = nouveauté  Comment puis-je récupérer le libellé ?  Merci")*

Bonjour,

Le souci vient d'un seul point : l'appel à getField. Quand on lui passe une clé (un field_namekey, donc une chaîne et pas un id numérique), getField a besoin du nom de la table du champ en 2e argument. Sans ce 2e argument, il fait sa requête avec field_table = '' (vide), ne trouve aucun champ, et renvoie false.

Du coup $this-&gt;badgeField vaut false, votre test if(!empty($this-&gt;badgeField) &amp;&amp; ...) n'est jamais vrai, le bloc n'est pas exécuté, et $badgesHtml reste vide. C'est pour ça que vous ne récupérez rien (ni le libellé, ni même la valeur).

La correction est d'indiquer la table du champ (pour un champ produit, c'est "product", la table affichée dans Affichage &gt; Champs personnalisés) :
Code:

$fieldClass = hikashop_get('class.field'); $this-&gt;badgeField = $fieldClass-&gt;getField('product_badges', 'product'); $this-&gt;sizeField = $fieldClass-&gt;getField('product_size_values', 'product');

Une fois le champ correctement chargé, votre show() renvoie directement le libellé, pas la valeur stockée. Pour un champ de type liste (dropdown, radio, case à cocher), show() convertit en interne la valeur stockée en libellé de l'option, et gère même le cas de plusieurs valeurs séparées par des virgules :
Code:

$badgesHtml = $this-&gt;fieldsClass-&gt;show($this-&gt;badgeField, $this-&gt;row-&gt;product_badges); // renvoie "nouveauté"

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

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

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

Less More

- Posts: 2697
- Thank you received: 74
-
-

5 months 3 hours ago -  5 months 3 hours ago [\#372214](#372214) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  Replied by *[erickb](/forum/user/4069-erickb "View erickb's Profile")* on topic *[Récupérer le nom des champs perso](/forum/5-support-en-francais-french-support-/910585-recuperer-le-nom-des-champs-perso#372214 "-- HikaShop version -- : 6.5 -- Joomla version -- : 6.1 -- PHP version -- : 8.4  Bonjour Dans product/listing&#95;div.php  Il load listing&#95;img&#95;title.php  Et je ne récupère rien Je ne veux pas la valeur qui est stockée dans le champ perso de la db mais bien le libellé badge&#95;new = nouveauté  Comment puis-je récupérer le libellé ?  Merci")*

Je vais tester ça mais je crois que je vais tout simplement donner valeur = libellé

Merci

Last edit: 5 months 3 hours ago by [erickb](/forum/user/4069-erickb "View erickb's Profile").

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

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