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

#   custom field value for variants

##

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

Less More

- Posts: 240
- Thank you received: 13
-
-

3 months 2 weeks ago [\#372580](#372580) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  *[custom field value for variants](/forum/25-install-update/910664-custom-field-value-for-variants#372580 "-- HikaShop version -- : 6.5.1 -- Joomla version -- : 6.1.2 -- PHP version -- : 8.3  hi i have several products and variants. I also have a custom field called seller percent celler percent field is filled for all main products, but not for variants. i want to set the value of this field for variants, equal to its parent main product")* was created by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")*

-- HikaShop version -- : 6.5.1
-- Joomla version -- : 6.1.2
-- PHP version -- : 8.3

hi
i have several products and variants.
I also have a custom field called seller percent
celler percent field is filled for all main products, but not for variants. i want to set the value of this field for variants, equal to its parent main product

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

Less More

- Posts: 86290
- Thank you received: 14269
-
-

3 months 2 weeks ago [\#372582](#372582) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[custom field value for variants](/forum/25-install-update/910664-custom-field-value-for-variants#372582 "-- HikaShop version -- : 6.5.1 -- Joomla version -- : 6.1.2 -- PHP version -- : 8.3  hi i have several products and variants. I also have a custom field called seller percent celler percent field is filled for all main products, but not for variants. i want to set the value of this field for variants, equal to its parent main product")*

Hi,

HikaShop already automatically use dynamically the value of the main product for the variant display on the product page on the frontend if the value of the custom field is left empty in the variant.
Is that what you're talking about ?
Or are you talking about something else ?
Could you explain your use case ? What are you trying to do with that custom product field ?

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

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

Less More

- Posts: 240
- Thank you received: 13
-
-

3 months 2 weeks ago [\#372584](#372584) by [khashiz](/forum/user/61259-khashiz "View khashiz's Profile")  Replied by *[khashiz](/forum/user/61259-khashiz "View khashiz's Profile")* on topic *[custom field value for variants](/forum/25-install-update/910664-custom-field-value-for-variants#372584 "-- HikaShop version -- : 6.5.1 -- Joomla version -- : 6.1.2 -- PHP version -- : 8.3  hi i have several products and variants. I also have a custom field called seller percent celler percent field is filled for all main products, but not for variants. i want to set the value of this field for variants, equal to its parent main product")*

Thanks for the response.
In my case, i need the custom field value be filled in database for both main products and variants. Because we have developed a custom plugin which grabs the products directly from the database.
We are selling gold products. Our custom plugin has a unique formula to calculate the final product price base on global gold price and product weight.
So we grab the products, do some calculations and then update the prices.
In grabbing the products we get main products and variants separately

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

Less More

- Posts: 86290
- Thank you received: 14269
-
-

3 months 2 weeks ago [\#372587](#372587) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[custom field value for variants](/forum/25-install-update/910664-custom-field-value-for-variants#372587 "-- HikaShop version -- : 6.5.1 -- Joomla version -- : 6.1.2 -- PHP version -- : 8.3  hi i have several products and variants. I also have a custom field called seller percent celler percent field is filled for all main products, but not for variants. i want to set the value of this field for variants, equal to its parent main product")*

Hi,

The inheritance I mentioned is only a display-time fallback: when the variant's custom field is empty, HikaShop reads the main product's value on the fly to show it on the frontend. It never writes that value to the variant's own row, so if you read the database directly you'll still find the field empty on the variants.

Product custom fields are stored as columns of the hikashop_product table, and variants are rows of that same table (with product_parent_id pointing to the main product). So the column already exists on your variant rows, it's just not filled.

Two solutions:

1) A one-time (or scheduled) SQL query copying the value from the parent to the empty variants. Replace seller_percent with the real column name of your field (its "Column name" in the field configuration, not the label):
Code:

UPDATE &#96;#__hikashop_product&#96; AS v JOIN &#96;#__hikashop_product&#96; AS p ON p.product_id = v.product_parent_id SET v.seller_percent = p.seller_percent WHERE v.product_type = 'variant' AND (v.seller_percent IS NULL OR v.seller_percent = '');

2) Since your plugin already grabs the products from the database, the cleaner option is to do the fallback there: when a variant's field is empty, read the value from its product_parent_id row. This mirrors what HikaShop does and stays correct even when the main product's value changes later, whereas the SQL copy above is a snapshot that goes stale if you edit the main product afterwards.

I would recommend you go for option 2. That's the clean, long-term solution.

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

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

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

[](#top)
