Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
1971354a
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,发现更多精彩内容 >>
提交
1971354a
编写于
7月 19, 2017
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
产品status设置成关闭,则访问该产品跳转404页面
上级
5891faab
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
57 addition
and
15 deletion
+57
-15
app/appfront/modules/Catalog/block/product/Index.php
app/appfront/modules/Catalog/block/product/Index.php
+15
-1
app/appfront/modules/Catalog/controllers/ProductController.php
...ppfront/modules/Catalog/controllers/ProductController.php
+3
-5
app/apphtml5/modules/Catalog/block/product/Index.php
app/apphtml5/modules/Catalog/block/product/Index.php
+15
-1
app/apphtml5/modules/Catalog/controllers/ProductController.php
...pphtml5/modules/Catalog/controllers/ProductController.php
+3
-5
models/mongodb/Product.php
models/mongodb/Product.php
+4
-1
services/Product.php
services/Product.php
+7
-1
services/product/ProductMongodb.php
services/product/ProductMongodb.php
+10
-1
未找到文件。
app/appfront/modules/Catalog/block/product/Index.php
浏览文件 @
1971354a
...
@@ -37,7 +37,10 @@ class Index
...
@@ -37,7 +37,10 @@ class Index
{
{
$productImgSize
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgSize'
];
$productImgSize
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgSize'
];
$productImgMagnifier
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgMagnifier'
];
$productImgMagnifier
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgMagnifier'
];
$this
->
initProduct
();
if
(
!
$this
->
initProduct
()){
Yii
::
$service
->
url
->
redirect404
();
return
;
}
ReviewHelper
::
initReviewConfig
();
ReviewHelper
::
initReviewConfig
();
$ReviewAndStarCount
=
ReviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
$ReviewAndStarCount
=
ReviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
...
@@ -391,6 +394,16 @@ class Index
...
@@ -391,6 +394,16 @@ class Index
$primaryVal
=
Yii
::
$app
->
request
->
get
(
$primaryKey
);
$primaryVal
=
Yii
::
$app
->
request
->
get
(
$primaryKey
);
$this
->
_primaryVal
=
$primaryVal
;
$this
->
_primaryVal
=
$primaryVal
;
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
if
(
$product
)
{
$enableStatus
=
Yii
::
$service
->
product
->
getEnableStatus
();
if
(
$product
[
'status'
]
!=
$enableStatus
){
return
false
;
}
}
else
{
return
false
;
}
$this
->
_product
=
$product
;
$this
->
_product
=
$product
;
Yii
::
$app
->
view
->
registerMetaTag
([
Yii
::
$app
->
view
->
registerMetaTag
([
'name'
=>
'keywords'
,
'name'
=>
'keywords'
,
...
@@ -416,6 +429,7 @@ class Index
...
@@ -416,6 +429,7 @@ class Index
// 重新查询产品信息。
// 重新查询产品信息。
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
$this
->
_product
=
$product
;
$this
->
_product
=
$product
;
return
true
;
}
}
// 面包屑导航
// 面包屑导航
...
...
app/appfront/modules/Catalog/controllers/ProductController.php
浏览文件 @
1971354a
...
@@ -27,12 +27,10 @@ class ProductController extends AppfrontController
...
@@ -27,12 +27,10 @@ class ProductController extends AppfrontController
// 产品详细页面
// 产品详细页面
public
function
actionIndex
()
public
function
actionIndex
()
{
{
//$data = Yii::$service->product->apicoll();
//var_dump($data);
//echo 1;exit;
$data
=
$this
->
getBlock
()
->
getLastData
();
$data
=
$this
->
getBlock
()
->
getLastData
();
if
(
is_array
(
$data
)){
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
}
}
}
/**
/**
* Yii2 behaviors 可以参看地址:http://www.yiichina.com/doc/guide/2.0/concept-behaviors
* Yii2 behaviors 可以参看地址:http://www.yiichina.com/doc/guide/2.0/concept-behaviors
...
...
app/apphtml5/modules/Catalog/block/product/Index.php
浏览文件 @
1971354a
...
@@ -37,7 +37,10 @@ class Index
...
@@ -37,7 +37,10 @@ class Index
{
{
$productImgSize
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgSize'
];
$productImgSize
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgSize'
];
$productImgMagnifier
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgMagnifier'
];
$productImgMagnifier
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgMagnifier'
];
$this
->
initProduct
();
if
(
!
$this
->
initProduct
()){
Yii
::
$service
->
url
->
redirect404
();
return
;
}
ReviewHelper
::
initReviewConfig
();
ReviewHelper
::
initReviewConfig
();
$ReviewAndStarCount
=
ReviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
$ReviewAndStarCount
=
ReviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
...
@@ -391,6 +394,16 @@ class Index
...
@@ -391,6 +394,16 @@ class Index
$primaryVal
=
Yii
::
$app
->
request
->
get
(
$primaryKey
);
$primaryVal
=
Yii
::
$app
->
request
->
get
(
$primaryKey
);
$this
->
_primaryVal
=
$primaryVal
;
$this
->
_primaryVal
=
$primaryVal
;
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
if
(
$product
)
{
$enableStatus
=
Yii
::
$service
->
product
->
getEnableStatus
();
if
(
$product
[
'status'
]
!=
$enableStatus
){
return
false
;
}
}
else
{
return
false
;
}
$this
->
_product
=
$product
;
$this
->
_product
=
$product
;
Yii
::
$app
->
view
->
registerMetaTag
([
Yii
::
$app
->
view
->
registerMetaTag
([
'name'
=>
'keywords'
,
'name'
=>
'keywords'
,
...
@@ -416,6 +429,7 @@ class Index
...
@@ -416,6 +429,7 @@ class Index
// 重新查询产品信息。
// 重新查询产品信息。
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$primaryVal
);
$this
->
_product
=
$product
;
$this
->
_product
=
$product
;
return
true
;
}
}
// 面包屑导航
// 面包屑导航
...
...
app/apphtml5/modules/Catalog/controllers/ProductController.php
浏览文件 @
1971354a
...
@@ -27,12 +27,10 @@ class ProductController extends AppfrontController
...
@@ -27,12 +27,10 @@ class ProductController extends AppfrontController
// 网站信息管理
// 网站信息管理
public
function
actionIndex
()
public
function
actionIndex
()
{
{
//$data = Yii::$service->product->apicoll();
//var_dump($data);
//echo 1;exit;
$data
=
$this
->
getBlock
()
->
getLastData
();
$data
=
$this
->
getBlock
()
->
getLastData
();
if
(
is_array
(
$data
)){
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
}
}
}
public
function
behaviors
()
public
function
behaviors
()
...
...
models/mongodb/Product.php
浏览文件 @
1971354a
...
@@ -18,7 +18,10 @@ use yii\mongodb\ActiveRecord;
...
@@ -18,7 +18,10 @@ use yii\mongodb\ActiveRecord;
class
Product
extends
ActiveRecord
class
Product
extends
ActiveRecord
{
{
public
static
$_customProductAttrs
;
public
static
$_customProductAttrs
;
const
STATUS_ENABLE
=
1
;
const
STATUS_DISABLE
=
2
;
/**
/**
* mongodb collection 的名字,相当于mysql的table name
* mongodb collection 的名字,相当于mysql的table name
*/
*/
...
...
services/Product.php
浏览文件 @
1971354a
...
@@ -33,7 +33,13 @@ class Product extends Service
...
@@ -33,7 +33,13 @@ class Product extends Service
//$this->_category = new CategoryMysqldb;
//$this->_category = new CategoryMysqldb;
}
}
}
}
protected
function
actionGetEnableStatus
()
{
return
$this
->
_product
->
getEnableStatus
();
}
/**
/**
* 得到产品的所有的属性组。
* 得到产品的所有的属性组。
*/
*/
...
...
services/product/ProductMongodb.php
浏览文件 @
1971354a
...
@@ -25,7 +25,13 @@ class ProductMongodb implements ProductInterface
...
@@ -25,7 +25,13 @@ class ProductMongodb implements ProductInterface
{
{
return
'_id'
;
return
'_id'
;
}
}
/**
* 得到分类激活状态的值
*/
public
function
getEnableStatus
(){
return
Product
::
STATUS_ENABLE
;
}
public
function
getByPrimaryKey
(
$primaryKey
)
public
function
getByPrimaryKey
(
$primaryKey
)
{
{
if
(
$primaryKey
)
{
if
(
$primaryKey
)
{
...
@@ -80,6 +86,8 @@ class ProductMongodb implements ProductInterface
...
@@ -80,6 +86,8 @@ class ProductMongodb implements ProductInterface
}
}
}
}
}
}
/*
/*
* example filter:
* example filter:
...
@@ -478,6 +486,7 @@ class ProductMongodb implements ProductInterface
...
@@ -478,6 +486,7 @@ class ProductMongodb implements ProductInterface
$select
=
$filter
[
'select'
];
$select
=
$filter
[
'select'
];
$query
=
Product
::
find
()
->
asArray
();
$query
=
Product
::
find
()
->
asArray
();
$query
->
where
(
$where
);
$query
->
where
(
$where
);
$query
->
andWhere
([
'status'
=>
$this
->
getEnableStatus
()]);
if
(
is_array
(
$select
)
&&
!
empty
(
$select
))
{
if
(
is_array
(
$select
)
&&
!
empty
(
$select
))
{
$query
->
select
(
$select
);
$query
->
select
(
$select
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录