Example #1
0
 /**
  * Чистка лога изменения цен
  * @param int $countDay за последние количество дней
  */
 public function actionPriceChanges($countDay = 30)
 {
     if ($count = ShopProductPriceChange::find()->where(['<=', 'created_at', time() - 3600 * 24 * $countDay])->count()) {
         $this->stdout("Total price changes for delete: {$count}\n", Console::BOLD);
         $totalDeleted = ShopProductPriceChange::deleteAll(['<=', 'created_at', time() - 3600 * 24 * $countDay]);
         $this->stdout("Total deleted: {$totalDeleted}\n");
     } else {
         $this->stdout("Нечего удалять\n", Console::BOLD);
     }
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getShopProductPriceChanges()
 {
     return $this->hasMany(ShopProductPriceChange::className(), ['shop_product_price_id' => 'id'])->orderBy(['created_at' => SORT_DESC]);
 }