public function actionDelete($id) { $params = $this->getParams(); $accountId = $this->getAccountId(); $idstrList = explode(',', $id); $ids = []; foreach ($idstrList as $perId) { $ids[] = new \MongoId($perId); } //check the store goods are not on shelves if (!empty(StoreGoods::getOnSaleByIds($ids, $accountId))) { throw new InvalidParameterException(Yii::t('store', 'delete_on_shelves')); } $condition = ['_id' => ['$in' => $ids]]; if (StoreGoods::deleteAll($condition) == false) { throw new ServerErrorHttpException(Yii::t('common', 'delete_fail')); } Yii::$app->getResponse()->setStatusCode(204); }
public function delete($productIds) { Goods::deleteAll(['productId' => ['$in' => $productIds]]); StoreGoods::deleteAll(['productId' => ['$in' => $productIds]]); }