From: Alexander Smirnov Date: Thu, 13 Mar 2025 10:51:25 +0000 (+0300) Subject: [ERP-370] command to active=0 excessive prices dynamics X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5feafa4a63b3450cb64b7901be7b275c5969ec55;p=erp24_rep%2Fyii-erp24%2F.git [ERP-370] command to active=0 excessive prices dynamics --- 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'; + } +}