Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
9fc85f23
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9fc85f23
编写于
7月 31, 2019
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
分类和产品删除的时候,更新产品分类关系表(mysql)
上级
0789fb4f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
0 deletion
+27
-0
services/category/CategoryMysqldb.php
services/category/CategoryMysqldb.php
+19
-0
services/product/ProductMysqldb.php
services/product/ProductMysqldb.php
+8
-0
未找到文件。
services/category/CategoryMysqldb.php
浏览文件 @
9fc85f23
...
...
@@ -26,6 +26,10 @@ class CategoryMysqldb extends Service implements CategoryInterface
protected
$_categoryModel
;
protected
$_categoryProductModelName
=
'\fecshop\models\mysqldb\CategoryProduct'
;
protected
$_categoryProductModel
;
protected
$serializeAttrs
=
[
'name'
,
'menu_custom'
,
...
...
@@ -41,6 +45,8 @@ class CategoryMysqldb extends Service implements CategoryInterface
{
parent
::
init
();
list
(
$this
->
_categoryModelName
,
$this
->
_categoryModel
)
=
Yii
::
mapGet
(
$this
->
_categoryModelName
);
list
(
$this
->
_categoryProductModelName
,
$this
->
_categoryProductModel
)
=
\
Yii
::
mapGet
(
$this
->
_categoryProductModelName
);
}
// 保存的数据进行serialize序列化
...
...
@@ -298,11 +304,14 @@ class CategoryMysqldb extends Service implements CategoryInterface
Yii
::
$service
->
url
->
removeRewriteUrlKey
(
$url_key
);
$model
->
delete
();
$this
->
removeChildCate
(
$id
);
// delete category product relation
$this
->
removeCategoryProductRelationByCategoryId
(
$id
);
}
else
{
Yii
::
$service
->
helper
->
errors
->
add
(
"Category Remove Errors:ID:
{
id
}
is not exist."
,
[
'id'
=>
$id
]);
$deleteAll
=
false
;
}
}
return
$deleteAll
;
}
else
{
...
...
@@ -319,6 +328,8 @@ class CategoryMysqldb extends Service implements CategoryInterface
return
false
;
}
// delete category product relation
$this
->
removeCategoryProductRelationByCategoryId
(
$id
);
}
return
true
;
}
...
...
@@ -335,6 +346,8 @@ class CategoryMysqldb extends Service implements CategoryInterface
$url_key
=
$one
[
'url_key'
];
Yii
::
$service
->
url
->
removeRewriteUrlKey
(
$url_key
);
$one
->
delete
();
// delete category product relation
$this
->
removeCategoryProductRelationByCategoryId
(
$idVal
);
}
}
}
...
...
@@ -592,4 +605,10 @@ class CategoryMysqldb extends Service implements CategoryInterface
return
$arr
;
}
public
function
removeCategoryProductRelationByCategoryId
(
$category_id
)
{
return
$this
->
_categoryProductModel
->
deleteAll
([
'category_id'
=>
$category_id
]);
}
}
services/product/ProductMysqldb.php
浏览文件 @
9fc85f23
...
...
@@ -793,6 +793,7 @@ class ProductMysqldb extends Service implements ProductInterface
Yii
::
$service
->
helper
->
errors
->
add
(
'Product Remove Errors:ID:{id} is not exist'
,
[
'id'
=>
$id
]);
$removeAll
=
0
;
}
$this
->
removeCategoryProductRelationByProductId
(
$id
);
}
if
(
!
$removeAll
)
{
return
false
;
...
...
@@ -808,6 +809,7 @@ class ProductMysqldb extends Service implements ProductInterface
Yii
::
$service
->
search
->
removeByProductId
(
$model
[
$this
->
getPrimaryKey
()]);
Yii
::
$service
->
product
->
stock
->
removeProductStock
(
$id
);
$model
->
delete
();
$this
->
removeCategoryProductRelationByProductId
(
$id
);
//$this->removeChildCate($id);
}
else
{
Yii
::
$service
->
helper
->
errors
->
add
(
'Product Remove Errors:ID:{id} is not exist.'
,
[
'id'
=>
$id
]);
...
...
@@ -1148,4 +1150,10 @@ class ProductMysqldb extends Service implements ProductInterface
public
function
updateAllScoreToZero
(){
return
$this
->
_productModel
->
getCollection
()
->
update
([],
[
'score'
=>
0
]);
}
public
function
removeCategoryProductRelationByProductId
(
$product_id
)
{
return
$this
->
_categoryProductModel
->
deleteAll
([
'product_id'
=>
$product_id
]);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录