From 5feafa4a63b3450cb64b7901be7b275c5969ec55 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Thu, 13 Mar 2025 13:51:25 +0300 Subject: [PATCH] [ERP-370] command to active=0 excessive prices dynamics --- erp24/commands/PriceController.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 erp24/commands/PriceController.php diff --git a/erp24/commands/PriceController.php b/erp24/commands/PriceController.php new file mode 100644 index 00000000..8e0b56ec --- /dev/null +++ b/erp24/commands/PriceController.php @@ -0,0 +1,26 @@ +where(['or', ['region_id' => null], ['region_id' => 52]])->andWhere(['active' => 1])->all(); + $p = []; + foreach ($pricesDynamics as $pricesDynamic) { + /** @var $pricesDynamic PricesDynamic */ + $p[$pricesDynamic->region_id ?? 0][$pricesDynamic->product_id][$pricesDynamic->id] = true; + } + $indices = []; + foreach ($p[0] as $productId => $pdId) { + if ($p[52][$productId]) { + $indices[] = array_keys($pdId)[0]; + } + } + PricesDynamic::updateAll(['active' => 0], ['id' => $indices]); + return 'ok'; + } +} -- 2.39.5