From f0aec63a7c206813c5e117107ef7a11ec7aede7b Mon Sep 17 00:00:00 2001 From: liugang Date: Sat, 8 Oct 2022 15:33:59 +0800 Subject: [PATCH] * Add a function to activate a product. --- module/product/model.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/module/product/model.php b/module/product/model.php index a87342024c..e20ae23e86 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -893,6 +893,25 @@ class productModel extends model if(!dao::isError()) return common::createChanges($oldProduct, $product); } + /** + * Activate a product. + * + * @param int $productID. + * @access public + * @return bool | array + */ + public function activate($productID) + { + $oldProduct = $this->getById($productID); + $product = (object)array('status' => 'normal'); + + $this->dao->update(TABLE_PRODUCT)->data($product)->where('id')->eq((int)$productID)->exec(); + + if(dao::isError()) return false; + + return common::createChanges($oldProduct, $product); + } + /** * Manage line. *