From ce2f46379a360f11fcb7a0331cf317afad4dd4c2 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Fri, 7 Feb 2025 16:52:46 +0100 Subject: [PATCH] NEW shipment with product in cache --- htdocs/expedition/card.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index a19523f9d7b..0802d1b9b32 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2409,6 +2409,7 @@ if ($action == 'create') { print ''; // Loop on each product to send/sent + $conf->cache['product'] = array(); for ($i = 0; $i < $num_prod; $i++) { $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); @@ -2429,8 +2430,14 @@ if ($action == 'create') { if ($lines[$i]->fk_product > 0) { // Define output language if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { - $prod = new Product($db); - $prod->fetch($lines[$i]->fk_product); + $product_id = $lines[$i]->fk_product; + if (!isset($conf->cache['product'][$product_id])) { + $prod = new Product($db); + $prod->fetch($product_id); + $conf->cache['product'][$product_id] = $prod; + } else { + $prod = $conf->cache['product'][$product_id]; + } $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; } else { $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label);