Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
7b8f7a6e
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
17
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,体验更适合开发者的 AI 搜索 >>
提交
7b8f7a6e
编写于
7月 26, 2019
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
product group attr , change config from database
上级
807849d7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
0 deletion
+75
-0
services/Product.php
services/Product.php
+75
-0
未找到文件。
services/Product.php
浏览文件 @
7b8f7a6e
...
...
@@ -71,6 +71,7 @@ class Product extends Service
public
function
init
()
{
parent
::
init
();
// 从数据库配置中得到值, 设置成当前service存储,是Mysqldb 还是 Mongodb
$config
=
Yii
::
$app
->
store
->
get
(
'service_db'
,
'category_and_product'
);
$this
->
storage
=
'ProductMysqldb'
;
...
...
@@ -79,6 +80,8 @@ class Product extends Service
}
$currentService
=
$this
->
getStorageService
(
$this
);
$this
->
_product
=
new
$currentService
();
// 从数据库配置数据,初始化customAttrGroup
$this
->
initCustomAttrGroup
();
}
// 动态更改为mongodb model
public
function
changeToMongoStorage
()
...
...
@@ -100,6 +103,78 @@ class Product extends Service
{
return
$this
->
_product
->
getEnableStatus
();
}
// 从数据库配置数据,初始化customAttrGroup
protected
function
initCustomAttrGroup
()
{
$attrPrimaryKey
=
$this
->
attr
->
getPrimaryKey
();
$attrGroupPrimaryKey
=
$this
->
attrGroup
->
getPrimaryKey
();
$allGroupColl
=
$this
->
attrGroup
->
getActiveAllColl
();
// attr
$allAttrColl
=
$this
->
attr
->
getActiveAllColl
();
$attrTypeColl
=
[];
if
(
$allAttrColl
)
{
foreach
(
$allAttrColl
as
$one
)
{
$attrTypeColl
[
$one
[
$attrPrimaryKey
]]
=
$one
;
}
}
$customAttrGroupArr
=
[];
if
(
$allGroupColl
)
{
foreach
(
$allGroupColl
as
$one
)
{
$groupName
=
$one
[
'name'
];
$attr_ids
=
$one
[
'attr_ids'
];
if
(
!
is_array
(
$attr_ids
)
||
empty
(
$attr_ids
))
{
continue
;
}
$attr_ids
=
\
fec\helpers\CFunc
::
array_sort
(
$attr_ids
,
'sort_order'
,
'desc'
);
//var_dump($attr_ids);exit;
foreach
(
$attr_ids
as
$attr_id_one
)
{
if
(
!
is_array
(
$attr_id_one
))
{
continue
;
}
$attr_id
=
$attr_id_one
[
'attr_id'
];
$attr_sort_order
=
$attr_id_one
[
'sort_order'
];
$attrOne
=
$attrTypeColl
[
$attr_id
];
if
(
!
$attrOne
)
{
continue
;
}
$attrName
=
$attrOne
[
'name'
];
$attrType
=
$attrOne
[
'attr_type'
];
$attrInfo
=
[
'dbtype'
=>
$attrOne
[
'db_type'
],
'name'
=>
$attrName
,
'showAsImg'
=>
$attrOne
[
'show_as_img'
]
==
1
?
true
:
false
,
'sort_order'
=>
$attr_sort_order
,
];
$displayType
=
$attrOne
[
'display_type'
];
$displayInfo
=
[];
if
(
$displayType
==
'inputString-Lang'
)
{
$displayInfo
[
'type'
]
=
'inputString'
;
$displayInfo
[
'lang'
]
=
true
;
}
else
{
$displayInfo
[
'type'
]
=
$displayType
;
}
if
(
is_array
(
$attrOne
[
'display_data'
]))
{
$d_arr
=
[];
foreach
(
$attrOne
[
'display_data'
]
as
$o
)
{
if
(
$o
[
'key'
])
{
$d_arr
[]
=
$o
[
'key'
];
}
}
$displayInfo
[
'data'
]
=
$d_arr
;
}
$attrInfo
[
'display'
]
=
$displayInfo
;
$customAttrGroupArr
[
$groupName
][
$attrType
][
$attrName
]
=
$attrInfo
;
}
}
}
$this
->
customAttrGroup
=
$customAttrGroupArr
;
//var_dump($customAttrGroupArr);exit;
}
/**
* 得到产品的所有的属性组。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录