public function viewCounter($id) { $counter = StoreProductViews::model()->findByAttributes(['product_id' => $id]); if ($counter) { $command = Yii::app()->db->createCommand(); $command->update('site_store_product_views', array('product_views' => $counter->product_views + 1), 'product_id=:product_id', array(':product_id' => $id)); } else { $counter = new StoreProductViews(); $counter->product_id = $id; $counter->product_views = 1; $counter->save(); } }
public function actionClearpopular() { Yii::app()->setImport(['application.modules.store.models.*']); StoreProductViews::model()->deleteAll(); }