From 347c330ec6660735c24818bc4f9688a03993a813 Mon Sep 17 00:00:00 2001 From: atm-corentin Date: Wed, 15 Jul 2026 09:43:13 +0200 Subject: [PATCH 1/5] NEW : show product variants by default in product list Add option PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST (Yes/No) in the variants module setup. When enabled, the "Show child products" checkbox of the products list (product/list.php) is ticked by default, so variant child products are visible without having to tick it manually. The default value keeps the current behaviour (variants hidden), so there is no regression for existing installs. The checkbox state is now always carried in the list parameters so an explicit "off" survives pagination and sorting even when the default is "on". Note: this is unrelated to PRODUIT_ATTRIBUTES_HIDECHILD, which only drives the product selectors, not the products list SQL query. --- ChangeLog | 1 + htdocs/langs/en_US/products.lang | 2 ++ htdocs/product/list.php | 18 ++++++++++++++---- htdocs/variants/admin/admin.php | 8 ++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a64c0cbc1ae64..820c5f59ef5fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -672,6 +672,7 @@ NEW: Add conf PDF_HIDE_LINKED_OBJECT_IN_PUBLIC_NOTE to hide linked object in pub NEW: Add MULTICURRENCY_SHOW_ALSO_MAIN_CURRENCY_ON_PDF for legal requirement that need both currencies on PDF NEW: Add note public and private on order export NEW: Finish dev for API_ENABLE_COUNT_CALLS (count of API use is visible on user API key field) +NEW: Add option PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST to show product variants by default in the products list For developers: --------------- diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index eda839c09a94f..bed3e536b2079 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -369,6 +369,8 @@ ProductCombinationAlreadyUsed=There was an error while deleting the variant. Ple ProductCombinations=Variants PropagateVariant=Propagate variants HideProductCombinations=Hide products variant in the products selector +ShowProductCombinationsInList=Show product variants by default in the products list +ShowProductCombinationsInListHelp=When enabled, the "Show child products" checkbox of the products list is ticked by default, so product variants are visible without having to tick it manually. Users can still untick it to hide them. ProductCombination=Variant NewProductCombination=New variant EditProductCombination=Editing variant diff --git a/htdocs/product/list.php b/htdocs/product/list.php index eb6166c430c7d..15fa5fb5d64ec 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -124,9 +124,18 @@ $type = GETPOST("type", 'alpha'); // Show/hide child product variants +// The default state is driven by the option PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST (0 = hidden, 1 = shown). +// An unchecked checkbox is not posted, so we rely on GETPOSTISSET and the search button to tell apart a +// fresh page load (apply default) from a form voluntarily submitted with the box unchecked (respect off). $show_childproducts = 0; if (isModEnabled('variants')) { - $show_childproducts = GETPOST('search_show_childproducts'); + if (GETPOSTISSET('search_show_childproducts')) { + $show_childproducts = GETPOSTINT('search_show_childproducts'); + } elseif (GETPOST('button_search', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha')) { + $show_childproducts = 0; // form submitted with the box unchecked -> respect off + } else { + $show_childproducts = getDolGlobalInt('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'); // fresh page load -> default + } } $diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id; @@ -400,7 +409,7 @@ $search_finished = ''; //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type. - $show_childproducts = ''; + $show_childproducts = getDolGlobalInt('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'); $search_import_key = ''; $search_stockable_product = ''; $search_accountancy_code_sell = ''; @@ -826,8 +835,9 @@ if ($fourn_id > 0) { $param .= "&fourn_id=".urlencode((string) ($fourn_id)); } -if ($show_childproducts) { - $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : ""); +if (isModEnabled('variants')) { + // Always carry the state (0 or 1) so pagination and sorting preserve an explicit "off" even when the default is "on" + $param .= "&search_show_childproducts=".urlencode((string) ($show_childproducts ? 1 : 0)); } if ($type != '') { $param .= '&type='.urlencode((string) ($type)); diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index 3bc3660fabd0b..7296aa24480d6 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -55,6 +55,11 @@ $error++; } + if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST', GETPOST('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'), 'chaine', 0, '', $conf->entity)) { + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + $error++; + } + if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); $error++; @@ -94,6 +99,9 @@ print ''.$langs->trans('HideProductCombinations').''; print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD", getDolGlobalString('PRODUIT_ATTRIBUTES_HIDECHILD'), 1).''; +print ''.$form->textwithpicto($langs->trans('ShowProductCombinationsInList'), $langs->trans('ShowProductCombinationsInListHelp')).''; +print $form->selectyesno("PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST", getDolGlobalString('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'), 1).''; + print ''.$langs->trans('CombinationsSeparator').''; $separator = getDolGlobalString('PRODUIT_ATTRIBUTES_SEPARATOR', '_'); From 3b28d387746e73682d8429612cac3a89b8384d46 Mon Sep 17 00:00:00 2001 From: atm-corentin Date: Wed, 15 Jul 2026 09:56:08 +0200 Subject: [PATCH 2/5] NEW : add fr_FR and es_ES translations for show variants in list --- htdocs/langs/es_ES/products.lang | 2 ++ htdocs/langs/fr_FR/products.lang | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/langs/es_ES/products.lang b/htdocs/langs/es_ES/products.lang index c82a99783015f..f20920b565ceb 100644 --- a/htdocs/langs/es_ES/products.lang +++ b/htdocs/langs/es_ES/products.lang @@ -373,6 +373,8 @@ ProductCombinationAlreadyUsed=Ha ocurrido un error al eliminar la variante. Comp ProductCombinations=Variantes PropagateVariant=Propagar variantes HideProductCombinations=Ocultar las variantes en el selector de productos +ShowProductCombinationsInList=Mostrar las variantes por defecto en la lista de productos +ShowProductCombinationsInListHelp=Cuando está activado, la casilla «Mostrar productos hijos» de la lista de productos está marcada por defecto, de modo que las variantes son visibles sin tener que marcarla manualmente. Los usuarios pueden desmarcarla para ocultarlas. ProductCombination=Variante NewProductCombination=Nueva variante EditProductCombination=Editando variante diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index e1094542b3457..9541bf427db55 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -373,6 +373,8 @@ ProductCombinationAlreadyUsed=Une erreur s'est produite lors de la suppression d ProductCombinations=Variantes PropagateVariant=Propager les variantes HideProductCombinations=Cacher les variantes dans les listes de sélection des produits +ShowProductCombinationsInList=Afficher les variantes par défaut dans la liste des produits +ShowProductCombinationsInListHelp=Lorsque cette option est activée, la case « Afficher les produits enfants » de la liste des produits est cochée par défaut, afin que les variantes soient visibles sans avoir à la cocher manuellement. Les utilisateurs peuvent toujours la décocher pour les masquer. ProductCombination=Variante NewProductCombination=Nouvelle variante EditProductCombination=Editer les variantes From 2c2bea6cb1a62a7afef1467b65226dc7b53d0d9d Mon Sep 17 00:00:00 2001 From: atm-corentin Date: Wed, 15 Jul 2026 10:10:40 +0200 Subject: [PATCH 3/5] FIX : keep product variants visible when searching the list --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 15fa5fb5d64ec..ece520cbf8cfe 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -994,7 +994,7 @@ // Show/hide child variant products if (isModEnabled('variants')) { $moreforfilter .= '
'; - $moreforfilter .= ''; + $moreforfilter .= ''; $moreforfilter .= ' '; $moreforfilter .= '
'; } From 73b6a0358bd3fef6a896784409526b8bf0cca065 Mon Sep 17 00:00:00 2001 From: atm-corentin Date: Wed, 15 Jul 2026 10:24:20 +0200 Subject: [PATCH 4/5] DOC : mark backported code with target Dolibarr version 24.0 --- htdocs/langs/en_US/products.lang | 1 + htdocs/langs/es_ES/products.lang | 1 + htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/list.php | 8 ++++++-- htdocs/variants/admin/admin.php | 3 +++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index bed3e536b2079..394b2c2996f77 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -369,6 +369,7 @@ ProductCombinationAlreadyUsed=There was an error while deleting the variant. Ple ProductCombinations=Variants PropagateVariant=Propagate variants HideProductCombinations=Hide products variant in the products selector +# BACKPORT ATM #757 - keys natives dès Dolibarr 24.0, à retirer après upgrade vers 24+ ShowProductCombinationsInList=Show product variants by default in the products list ShowProductCombinationsInListHelp=When enabled, the "Show child products" checkbox of the products list is ticked by default, so product variants are visible without having to tick it manually. Users can still untick it to hide them. ProductCombination=Variant diff --git a/htdocs/langs/es_ES/products.lang b/htdocs/langs/es_ES/products.lang index f20920b565ceb..af84478bff0c6 100644 --- a/htdocs/langs/es_ES/products.lang +++ b/htdocs/langs/es_ES/products.lang @@ -373,6 +373,7 @@ ProductCombinationAlreadyUsed=Ha ocurrido un error al eliminar la variante. Comp ProductCombinations=Variantes PropagateVariant=Propagar variantes HideProductCombinations=Ocultar las variantes en el selector de productos +# BACKPORT ATM #757 - keys natives dès Dolibarr 24.0, à retirer après upgrade vers 24+ ShowProductCombinationsInList=Mostrar las variantes por defecto en la lista de productos ShowProductCombinationsInListHelp=Cuando está activado, la casilla «Mostrar productos hijos» de la lista de productos está marcada por defecto, de modo que las variantes son visibles sin tener que marcarla manualmente. Los usuarios pueden desmarcarla para ocultarlas. ProductCombination=Variante diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 9541bf427db55..9fdca42c3b454 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -373,6 +373,7 @@ ProductCombinationAlreadyUsed=Une erreur s'est produite lors de la suppression d ProductCombinations=Variantes PropagateVariant=Propager les variantes HideProductCombinations=Cacher les variantes dans les listes de sélection des produits +# BACKPORT ATM #757 - keys natives dès Dolibarr 24.0, à retirer après upgrade vers 24+ ShowProductCombinationsInList=Afficher les variantes par défaut dans la liste des produits ShowProductCombinationsInListHelp=Lorsque cette option est activée, la case « Afficher les produits enfants » de la liste des produits est cochée par défaut, afin que les variantes soient visibles sans avoir à la cocher manuellement. Les utilisateurs peuvent toujours la décocher pour les masquer. ProductCombination=Variante diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ece520cbf8cfe..2b26f50b69cd0 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -123,6 +123,7 @@ $search_units = GETPOST('search_units', 'int'); $type = GETPOST("type", 'alpha'); +// >>> BACKPORT ATM #757 (PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST) - natif dès Dolibarr 24.0, à retirer après upgrade vers 24+ // Show/hide child product variants // The default state is driven by the option PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST (0 = hidden, 1 = shown). // An unchecked checkbox is not posted, so we rely on GETPOSTISSET and the search button to tell apart a @@ -137,6 +138,7 @@ $show_childproducts = getDolGlobalInt('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'); // fresh page load -> default } } +// <<< BACKPORT ATM #757 $diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id; @@ -409,7 +411,7 @@ $search_finished = ''; //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type. - $show_childproducts = getDolGlobalInt('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'); + $show_childproducts = getDolGlobalInt('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'); // BACKPORT ATM #757 - natif dès Dolibarr 24.0 (défaut au lieu de '') $search_import_key = ''; $search_stockable_product = ''; $search_accountancy_code_sell = ''; @@ -835,10 +837,12 @@ if ($fourn_id > 0) { $param .= "&fourn_id=".urlencode((string) ($fourn_id)); } +// >>> BACKPORT ATM #757 - natif dès Dolibarr 24.0, à retirer après upgrade vers 24+ if (isModEnabled('variants')) { // Always carry the state (0 or 1) so pagination and sorting preserve an explicit "off" even when the default is "on" $param .= "&search_show_childproducts=".urlencode((string) ($show_childproducts ? 1 : 0)); } +// <<< BACKPORT ATM #757 if ($type != '') { $param .= '&type='.urlencode((string) ($type)); } @@ -994,7 +998,7 @@ // Show/hide child variant products if (isModEnabled('variants')) { $moreforfilter .= '
'; - $moreforfilter .= ''; + $moreforfilter .= ''; // BACKPORT ATM #757 - value="1" natif dès Dolibarr 24.0 (sinon case cochée soumet "on" -> GETPOSTINT=0) $moreforfilter .= ' '; $moreforfilter .= '
'; } diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index 7296aa24480d6..68a43cac95138 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -55,6 +55,7 @@ $error++; } + // BACKPORT ATM #757 - natif dès Dolibarr 24.0, à retirer après upgrade vers 24+ if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST', GETPOST('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'), 'chaine', 0, '', $conf->entity)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); $error++; @@ -99,8 +100,10 @@ print ''.$langs->trans('HideProductCombinations').''; print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD", getDolGlobalString('PRODUIT_ATTRIBUTES_HIDECHILD'), 1).''; +// >>> BACKPORT ATM #757 - natif dès Dolibarr 24.0, à retirer après upgrade vers 24+ print ''.$form->textwithpicto($langs->trans('ShowProductCombinationsInList'), $langs->trans('ShowProductCombinationsInListHelp')).''; print $form->selectyesno("PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST", getDolGlobalString('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'), 1).''; +// <<< BACKPORT ATM #757 print ''.$langs->trans('CombinationsSeparator').''; From 1fc2ffe85d48a0e0fd55a40e28185c6a1a604815 Mon Sep 17 00:00:00 2001 From: atm-corentin Date: Thu, 16 Jul 2026 11:21:44 +0200 Subject: [PATCH 5/5] REFACTOR : apply PR #758 review on variants list backport - admin.php: wrap the set_const block with >>>/<<< BACKPORT markers (consistency) - admin.php: add missing 'int' 2nd param to GETPOST for the new const - ChangeLog: tag the entry as backport ATM #757 (native in Dolibarr 24.0) --- ChangeLog | 2 +- htdocs/variants/admin/admin.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 820c5f59ef5fd..307d109b53e5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -672,7 +672,7 @@ NEW: Add conf PDF_HIDE_LINKED_OBJECT_IN_PUBLIC_NOTE to hide linked object in pub NEW: Add MULTICURRENCY_SHOW_ALSO_MAIN_CURRENCY_ON_PDF for legal requirement that need both currencies on PDF NEW: Add note public and private on order export NEW: Finish dev for API_ENABLE_COUNT_CALLS (count of API use is visible on user API key field) -NEW: Add option PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST to show product variants by default in the products list +NEW: Add option PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST to show product variants by default in the products list (backport ATM #757, native in Dolibarr 24.0) For developers: --------------- diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index 68a43cac95138..aa00fe480b2b5 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -55,11 +55,12 @@ $error++; } - // BACKPORT ATM #757 - natif dès Dolibarr 24.0, à retirer après upgrade vers 24+ - if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST', GETPOST('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST'), 'chaine', 0, '', $conf->entity)) { + // >>> BACKPORT ATM #757 - natif dès Dolibarr 24.0, à retirer après upgrade vers 24+ + if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST', GETPOST('PRODUIT_ATTRIBUTES_SHOWCHILD_IN_LIST', 'int'), 'chaine', 0, '', $conf->entity)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); $error++; } + // <<< BACKPORT ATM #757 if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');