src/console/controllers/MigrateController.php
public function actionRemoveDublicatePrices()
    {
        /**
         * @var ShopProductPrice $price
         */
        foreach (ShopProductPrice::find()->each(1000) as $price) {
            $prices = ShopProductPrice::find()
                ->where(['type_price_id' => $price->type_price_id])
                ->andWhere(['product_id' => $price->product_id])
                ->andWhere(["!=", 'id', $price->id])->all();

            $this->stdout("price: {$price->id}\n");
            if (!$prices) {
                continue;
            } else {
                $total = count($prices);

                $removePrices = ShopProductPrice::find()->where(['type_price_id' => $price->type_price_id])
                    ->andWhere(['product_id' => $price->product_id])
                    ->orderBy(['price' => SORT_ASC])
                    ->limit($total)
                    //->andWhere(["!=", 'id', $price->id])
                    ->all();

                $forRemove = count($removePrices);
                foreach ($removePrices as $price) {
                    $price->delete();
                }

                $this->stdout("\tЕсть дубли, удалено {$forRemove}\n", Console::FG_RED);
            }
        }
    }
public function actionRemoveDublicatePrices()
    {
        /**
         * @var ShopProductPrice $price
         */
        foreach (ShopProductPrice::find()->each(1000) as $price) {
            $prices = ShopProductPrice::find()
                ->where(['type_price_id' => $price->type_price_id])
                ->andWhere(['product_id' => $price->product_id])
                ->andWhere(["!=", 'id', $price->id])->all();

            $this->stdout("price: {$price->id}\n");
            if (!$prices) {
                continue;
            } else {
                $total = count($prices);

                $removePrices = ShopProductPrice::find()->where(['type_price_id' => $price->type_price_id])
                    ->andWhere(['product_id' => $price->product_id])
                    ->orderBy(['price' => SORT_ASC])
                    ->limit($total)
                    //->andWhere(["!=", 'id', $price->id])
                    ->all();

                $forRemove = count($removePrices);
                foreach ($removePrices as $price) {
                    $price->delete();
                }

                $this->stdout("\tЕсть дубли, удалено {$forRemove}\n", Console::FG_RED);
            }
        }
    }
Просмотр созданных бекапов баз данных