From 3e5a7be6982496aa9e0f84b34cfab04622d04e9b Mon Sep 17 00:00:00 2001 From: Terry <2358269014@qq.com> Date: Thu, 4 Mar 2021 09:55:22 +0800 Subject: [PATCH] product attr model --- services/product/attr/AttrMysqldb.php | 15 +++++++++++++++ services/product/attrgroup/AttrGroupMysqldb.php | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/services/product/attr/AttrMysqldb.php b/services/product/attr/AttrMysqldb.php index 8d0a26c6..3e221f62 100644 --- a/services/product/attr/AttrMysqldb.php +++ b/services/product/attr/AttrMysqldb.php @@ -59,6 +59,21 @@ public function getByPrimaryKey($primaryKey = null) } } + public function getByAttrTypeAndName($attr_type, $name) + { + if ($attr_type && $name) { + $one = $this->_attrModel->findOne([ + 'attr_type' => $attr_type, + 'name' => $name, + ]); + + return $one; + } else { + + return new $this->_attrModel(); + } + } + public function getByRemoteId($remoteId) { if (!$remoteId) { diff --git a/services/product/attrgroup/AttrGroupMysqldb.php b/services/product/attrgroup/AttrGroupMysqldb.php index 68b0318b..f5317b59 100644 --- a/services/product/attrgroup/AttrGroupMysqldb.php +++ b/services/product/attrgroup/AttrGroupMysqldb.php @@ -60,6 +60,18 @@ public function getByPrimaryKey($primaryKey = null) } } + public function getByName($name) + { + if ($name) { + $one = $this->_attrGroupModel->findOne(['name' => $name]); + + return $one; + } else { + + return new $this->_attrGroupModel(); + } + } + /* * example filter: * [