From 83d1077a69670a0a8b9b002f56b9b6b319d5250c Mon Sep 17 00:00:00 2001 From: lnormandon Date: Mon, 27 May 2024 10:31:15 +0200 Subject: [PATCH] Add originals prices on loop --- Config/module.xml | 2 +- LoopExtend/CustomerFamilyPriceListener.php | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Config/module.xml b/Config/module.xml index f39df21..3d61b78 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -7,7 +7,7 @@ Famille de clients et prix d'achat - 3.1.5 + 3.1.6 Guillaume Barral / Etienne Perriere gbarral@openstudio.fr / eperriere@openstudio.fr diff --git a/LoopExtend/CustomerFamilyPriceListener.php b/LoopExtend/CustomerFamilyPriceListener.php index 22e8244..e554c33 100644 --- a/LoopExtend/CustomerFamilyPriceListener.php +++ b/LoopExtend/CustomerFamilyPriceListener.php @@ -258,8 +258,13 @@ private function changeProductPrice( $priceTax = $taxedPrice - $price; + $loopResultRow->set("HAS_CUSTOMER_FAMILY_PRICE",1); + // Set new price & tax into the loop $loopResultRow + ->set("ORIGINAL_PRICE", $loopResultRow->get("PRICE")) + ->set("ORIGINAL_PRICE_TAX", $loopResultRow->get("PRICE_TAX")) + ->set("ORIGINAL_TAXED_PRICE", $loopResultRow->get("TAXED_PRICE")) ->set("PRICE", $price) ->set("PRICE_TAX", $priceTax) ->set("TAXED_PRICE", $taxedPrice); @@ -288,8 +293,13 @@ private function changeProductPrice( $promoPriceTax = $taxedPromoPrice - $promoPrice; + $loopResultRow->set("HAS_CUSTOMER_FAMILY_PROMO_PRICE",1); + // Set new promo price & tax into the loop $loopResultRow + ->set("ORIGINAL_PROMO_PRICE", $loopResultRow->get("PROMO_PRICE")) + ->set("ORIGINAL_PROMO_PRICE_TAX", $loopResultRow->get("PROMO_PRICE_TAX")) + ->set("ORIGINAL_TAXED_PROMO_PRICE", $loopResultRow->get("TAXED_PROMO_PRICE")) ->set("PROMO_PRICE", $promoPrice) ->set("PROMO_PRICE_TAX", $promoPriceTax) ->set("TAXED_PROMO_PRICE", $taxedPromoPrice); @@ -299,16 +309,21 @@ private function changeProductPrice( ? $product->getVirtualColumn('CUSTOMER_FAMILY_PRODUCT_PROMO') : null; - if (empty($isPromo) && $product->hasVirtualColumn('is_promo')) { + if ($isPromo === null && $product->hasVirtualColumn('is_promo')) { $isPromo = $product->getVirtualColumn('is_promo'); } + // If current row is a product if ($product instanceof Product) { $loopResultRow + ->set("ORIGINAL_BEST_PRICE", $loopResultRow->get("BEST_PRICE")) + ->set("ORIGINAL_BEST_PRICE_TAX", $loopResultRow->get("BEST_PRICE_TAX")) + ->set("ORIGINAL_BEST_TAXED_PRICE", $loopResultRow->get("BEST_TAXED_PRICE")) + ->set("IS_PROMO", $isPromo === 1) ->set("BEST_PRICE", $isPromo ? $promoPrice : $price) ->set("BEST_PRICE_TAX", $isPromo ? $promoPriceTax : $priceTax) ->set("BEST_TAXED_PRICE", $isPromo ? $taxedPromoPrice : $taxedPrice); } } -} \ No newline at end of file +}