Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
9eebf6d0
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 搜索 >>
提交
9eebf6d0
编写于
7月 11, 2017
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
catalog modules 部分代码调整和注释
上级
d472d7eb
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
269 addition
and
88 deletion
+269
-88
app/appfront/modules/Catalog/block/category/Index.php
app/appfront/modules/Catalog/block/category/Index.php
+74
-18
app/appfront/modules/Catalog/block/favoriteproduct/Add.php
app/appfront/modules/Catalog/block/favoriteproduct/Add.php
+3
-0
app/appfront/modules/Catalog/block/product/CustomOption.php
app/appfront/modules/Catalog/block/product/CustomOption.php
+4
-2
app/appfront/modules/Catalog/block/product/Index.php
app/appfront/modules/Catalog/block/product/Index.php
+20
-10
app/appfront/modules/Catalog/block/product/Review.php
app/appfront/modules/Catalog/block/product/Review.php
+6
-2
app/appfront/modules/Catalog/block/reviewproduct/Add.php
app/appfront/modules/Catalog/block/reviewproduct/Add.php
+12
-4
app/appfront/modules/Catalog/block/reviewproduct/Lists.php
app/appfront/modules/Catalog/block/reviewproduct/Lists.php
+11
-4
app/appfront/modules/Catalog/controllers/CategoryController.php
...pfront/modules/Catalog/controllers/CategoryController.php
+4
-1
app/appfront/modules/Catalog/controllers/FavoriteproductController.php
...modules/Catalog/controllers/FavoriteproductController.php
+1
-1
app/appfront/modules/Catalog/controllers/ProductController.php
...ppfront/modules/Catalog/controllers/ProductController.php
+5
-2
app/apphtml5/modules/Catalog/block/category/Index.php
app/apphtml5/modules/Catalog/block/category/Index.php
+76
-16
app/apphtml5/modules/Catalog/block/favoriteproduct/Add.php
app/apphtml5/modules/Catalog/block/favoriteproduct/Add.php
+3
-0
app/apphtml5/modules/Catalog/block/product/CustomOption.php
app/apphtml5/modules/Catalog/block/product/CustomOption.php
+3
-1
app/apphtml5/modules/Catalog/block/product/Index.php
app/apphtml5/modules/Catalog/block/product/Index.php
+9
-8
app/apphtml5/modules/Catalog/block/product/Review.php
app/apphtml5/modules/Catalog/block/product/Review.php
+6
-2
app/apphtml5/modules/Catalog/block/reviewproduct/Add.php
app/apphtml5/modules/Catalog/block/reviewproduct/Add.php
+20
-12
app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php
app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php
+12
-5
未找到文件。
app/appfront/modules/Catalog/block/category/Index.php
浏览文件 @
9eebf6d0
...
...
@@ -18,18 +18,31 @@ use yii\base\InvalidValueException;
*/
class
Index
{
// 当前分类对象
protected
$_category
;
// 页面标题
protected
$_title
;
// 当前分类主键对应的值
protected
$_primaryVal
;
// 默认的排序字段
protected
$_defautOrder
;
// 默认的排序方向,升序还是降序
protected
$_defautOrderDirection
=
SORT_DESC
;
// 当前的where条件
protected
$_where
;
// url的参数,每页产品个数
protected
$_numPerPage
=
'numPerPage'
;
// url的参数,排序方向
protected
$_direction
=
'dir'
;
// url的参数,排序字段
protected
$_sort
=
'sort'
;
// url的参数,页数
protected
$_page
=
'p'
;
// url的参数,价格
protected
$_filterPrice
=
'price'
;
// url的参数,价格
protected
$_filterPriceAttr
=
'price'
;
// 产品总数
protected
$_productCount
;
protected
$_filter_attr
;
protected
$_numPerPageVal
;
...
...
@@ -77,7 +90,10 @@ class Index
return
$filter_category
;
}
/**
* @property $filter_category | Array
* 通过递归的方式,得到分类以及子分类的html。
*/
protected
function
getFilterCategoryHtml
(
$filter_category
=
''
)
{
$str
=
''
;
...
...
@@ -104,7 +120,10 @@ class Index
//exit;
return
$str
;
}
/**
* 得到产品页面的toolbar部分
* 也就是分类页面的分页工具条部分。
*/
protected
function
getProductPage
()
{
$productNumPerPage
=
$this
->
getNumPerPage
();
...
...
@@ -121,12 +140,15 @@ class Index
return
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_product_page'
,
$config
);
}
/**
* 分类页面toolbar部分:
* 产品排序,产品每页的产品个数等,为这些部分提供数据。
*/
protected
function
getQueryItem
()
{
$category_query
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$numPerPage
=
$category_query
[
'numPerPage'
];
$sort
=
$category_query
[
'sort'
];
$category_query
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
$numPerPage
=
$category_query
[
'numPerPage'
];
$sort
=
$category_query
[
'sort'
];
$frontNumPerPage
=
[];
if
(
is_array
(
$numPerPage
)
&&
!
empty
(
$numPerPage
))
{
$attrUrlStr
=
$this
->
_numPerPage
;
...
...
@@ -174,7 +196,14 @@ class Index
return
$data
;
}
/**
* @return Array
* 得到当前分类,侧栏用于过滤的属性数组,由三部分计算得出
* 1.全局默认属性过滤(catalog module 配置文件中配置 category_filter_attr),
* 2.当前分类属性过滤,也就是分类表的 filter_product_attr_selected 字段
* 3.当前分类去除的属性过滤,也就是分类表的 filter_product_attr_unselected
* 最终出来一个当前分类,用于过滤的属性数组。
*/
protected
function
getFilterAttr
()
{
if
(
!
$this
->
_filter_attr
)
{
...
...
@@ -190,7 +219,9 @@ class Index
return
$this
->
_filter_attr
;
}
/**
* 得到分类侧栏用于属性过滤的部分数据
*/
protected
function
getRefineByInfo
()
{
$get_arr
=
Yii
::
$app
->
request
->
get
();
...
...
@@ -230,7 +261,9 @@ class Index
return
$refineInfo
;
}
/**
* 侧栏除价格外的其他属性过滤部分
*/
protected
function
getFilterInfo
()
{
$filter_info
=
[];
...
...
@@ -243,7 +276,9 @@ class Index
return
$filter_info
;
}
/**
* 侧栏价格过滤部分
*/
protected
function
getFilterPrice
()
{
$filter
=
[];
...
...
@@ -258,7 +293,9 @@ class Index
return
$filter
;
}
/**
* 格式化价格格式,侧栏价格过滤部分
*/
protected
function
getFormatFilterPrice
(
$price_item
)
{
list
(
$f_price
,
$l_price
)
=
explode
(
'-'
,
$price_item
);
...
...
@@ -274,7 +311,10 @@ class Index
return
$str
;
}
/**
* @property $str | String
* 字符串转换成数组。
*/
protected
function
getFilterArr
(
$str
)
{
$arr
=
[];
...
...
@@ -291,7 +331,9 @@ class Index
return
$arr
;
}
/**
* 用于搜索条件的排序部分
*/
protected
function
getOrderBy
()
{
$primaryKey
=
Yii
::
$service
->
category
->
getPrimaryKey
();
...
...
@@ -326,7 +368,12 @@ class Index
}
}
}
/**
* 分类页面的产品,每页显示的产品个数。
* 对于前端传递的个数参数,在后台验证一下是否是合法的个数(配置里面有一个分类产品个数列表)
* 如果不合法,则报异常
* 这个功能是为了防止分页攻击,伪造大量的不同个数的url,绕过缓存。
*/
protected
function
getNumPerPage
()
{
if
(
!
$this
->
_numPerPageVal
)
{
...
...
@@ -352,14 +399,18 @@ class Index
return
$this
->
_numPerPageVal
;
}
/**
* 得到当前第几页
*/
protected
function
getPageNum
()
{
$numPerPage
=
Yii
::
$app
->
request
->
get
(
$this
->
_page
);
return
$numPerPage
?
(
int
)
$numPerPage
:
1
;
}
/**
* 得到当前分类的产品
*/
protected
function
getCategoryProductColl
()
{
$select
=
[
...
...
@@ -384,7 +435,9 @@ class Index
//var_dump($filter);exit;
return
Yii
::
$service
->
category
->
product
->
getFrontList
(
$filter
);
}
/**
* 得到用于查询的where数组。
*/
protected
function
initWhere
()
{
$filterAttr
=
$this
->
getFilterAttr
();
...
...
@@ -408,7 +461,10 @@ class Index
//var_dump($where);exit;
return
$where
;
}
/**
* 分类部分的初始化
* 对一些属性进行赋值。
*/
protected
function
initCategory
()
{
$primaryKey
=
Yii
::
$service
->
category
->
getPrimaryKey
();
...
...
app/appfront/modules/Catalog/block/favoriteproduct/Add.php
浏览文件 @
9eebf6d0
...
...
@@ -17,6 +17,9 @@ use Yii;
*/
class
Add
{
/**
* 用户添加收藏产品
*/
public
function
getLastData
()
{
$product_id
=
Yii
::
$app
->
request
->
get
(
'product_id'
);
...
...
app/appfront/modules/Catalog/block/product/CustomOption.php
浏览文件 @
9eebf6d0
...
...
@@ -29,12 +29,14 @@ class CustomOption
//var_dump($items);exit;
return
[
'items'
=>
$items
,
'product_id'
=>
$this
->
product_id
,
'product_id'
=>
$this
->
product_id
,
'custom_option_arr'
=>
json_encode
(
$this
->
_custom_option_arr
),
'middle_img_width'
=>
$this
->
middle_img_width
,
];
}
/**
* 得到custom option 部分
*/
public
function
getAllItems
()
{
$custom_option_attr_info
=
Yii
::
$service
->
product
->
getCustomOptionAttrInfo
(
$this
->
attr_group
);
...
...
app/appfront/modules/Catalog/block/product/Index.php
浏览文件 @
9eebf6d0
...
...
@@ -18,12 +18,19 @@ use Yii;
*/
class
Index
{
// 当前产品
protected
$_product
;
// 产品页面的title
protected
$_title
;
// 产品的主键对应的值
protected
$_primaryVal
;
// 产品的spu属性数组。
protected
$_productSpuAttrArr
;
// 以图片方式显示的spu属性
protected
$_spuAttrShowAsImg
;
// 在产品详细页面,在橱窗图部分,以放大镜的方式显示的产品图片列表
protected
$_image_thumbnails
;
// 在产品详细页面,在产品描述部分显示的产品图片列表
protected
$_image_detail
;
public
function
getLastData
()
...
...
@@ -60,8 +67,10 @@ class Index
];
}
/**
*
* 对gallery 中的图片进行处理,只要 is_thumbnails=1 的图片,其他的过滤掉
* @property $product_images | Array ,产品的图片属性
* 根据图片数组,得到橱窗图,和描述图
* 橱窗图:在产品详细页面顶部,放大镜显示部分的产品列表
* 描述图,在产品description文字描述后面显示的产品图片。
*/
public
function
filterProductImg
(
$product_images
){
$this
->
_image_thumbnails
=
$product_images
;
...
...
@@ -88,7 +97,7 @@ class Index
}
/**
/**
废弃
* @property $data | Array 和当前产品的spu相同,但sku不同的产品 数组。
* @property $current_size | String 当前产品的size值
* @property $current_color | String 当前产品的颜色值
...
...
@@ -152,7 +161,9 @@ class Index
}
/**
* @property $select | Array , 需要查询的字段。
* 得到当前spu下面的所有的sku的数组、
* 这个是为了产品详细页面的spu下面的产品切换,譬如同一spu下的不同的颜色尺码切换。
*/
protected
function
getSpuData
(
$select
)
{
...
...
@@ -172,11 +183,10 @@ class Index
}
/**
* 显示这个的前提是,该产品所在属性组对应的spu_attr 只有color 和size 两种
* 也就是说,这个只针对服装做的一种方式,其他的会按照大众化的那种方式显示出来过滤。(下拉条)
* 这个有点像定制化的范畴,目前我只做了color和size这类
* 衣服类产品需要用到的属性,对于其他的类似属性,就需要自己做定制修改了.
* @return 返回和当前产品spu相同的其他产品,然后以颜色和尺码的方式罗列出来。
* @return Array得到spu下面的sku的spu属性的数据。用于在产品
* 得到spu下面的sku的spu属性的数据。用于在产品详细页面显示其他的sku
* 譬如页面:https://fecshop.appfront.fancyecommerce.com/raglan-sleeves-letter-printed-crew-neck-sweatshirt-53386451-77774122
* 该spu的其他sku的颜色尺码也在这里显示出来。
*/
protected
function
getSameSpuInfo
()
{
...
...
@@ -250,7 +260,7 @@ class Index
return
$spuShowArr
;
}
// spu属性部分
protected
function
getSpuAttrInfo
(
$spuAttr
,
$attrVal
,
$reverse_val_spu
)
{
$current
=
$this
->
_currentSpuAttrValArr
;
...
...
@@ -409,7 +419,7 @@ class Index
Yii
::
$service
->
page
->
breadcrumbs
->
active
=
false
;
}
}
// 买了的人还买了什么,通过产品字段取出来sku,然后查询得到。
protected
function
getProductBySkus
(
$skus
)
{
$buy_also_buy_sku
=
$this
->
_product
[
'buy_also_buy_sku'
];
...
...
app/appfront/modules/Catalog/block/product/Review.php
浏览文件 @
9eebf6d0
...
...
@@ -28,7 +28,9 @@ class Review
// 初始化当前appfront的设置,覆盖service的初始设置。
ReviewHelper
::
initReviewConfig
();
}
/**
* 得到当前spu下面的所有评论信息。
*/
public
function
getLastData
()
{
if
(
!
$this
->
spu
||
!
$this
->
product_id
)
{
...
...
@@ -48,7 +50,9 @@ class Review
];
}
}
/**
* 得到当前spu下面的所有评论信息。
*/
public
function
getReviewsBySpu
(
$spu
)
{
$review
=
Yii
::
$app
->
getModule
(
'catalog'
)
->
params
[
'review'
];
...
...
app/appfront/modules/Catalog/block/reviewproduct/Add.php
浏览文件 @
9eebf6d0
...
...
@@ -24,7 +24,9 @@ class Add
{
ReviewHelper
::
initReviewConfig
();
}
/**
* @return boolean , review页面是否开启验证码验证。
*/
public
function
getAddCaptcha
()
{
if
(
!
$this
->
_add_captcha
)
{
...
...
@@ -77,7 +79,10 @@ class Add
'url'
=>
Yii
::
$service
->
url
->
getUrl
(
$url_key
),
];
}
/**
* @property $editForm | Array
* @return boolean ,保存评论信息
*/
public
function
saveReview
(
$editForm
)
{
$add_captcha
=
$this
->
getAddCaptcha
();
...
...
@@ -135,7 +140,10 @@ class Add
return
true
;
}
/**
* @property $product | String Or Object
* 得到产品的价格信息
*/
protected
function
getProductPriceInfo
(
$product
)
{
$price
=
$product
[
'price'
];
...
...
@@ -145,7 +153,7 @@ class Add
return
Yii
::
$service
->
product
->
price
->
getCurrentCurrencyProductPriceInfo
(
$price
,
$special_price
,
$special_from
,
$special_to
);
}
// 废弃
protected
function
getSpuData
()
{
$spu
=
$this
->
_product
[
'spu'
];
...
...
app/appfront/modules/Catalog/block/reviewproduct/Lists.php
浏览文件 @
9eebf6d0
...
...
@@ -28,9 +28,13 @@ class Lists
public
function
__construct
()
{
// 初始化服务
ReviewHelper
::
initReviewConfig
();
}
/**
* @property $countTotal | Int
* 得到toolbar的分页部分
*/
protected
function
getProductPage
(
$countTotal
)
{
if
(
$countTotal
<=
$this
->
numPerPage
)
{
...
...
@@ -47,7 +51,7 @@ class Lists
return
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_product_page'
,
$config
);
}
// 初始化参数
public
function
initParam
()
{
$this
->
pageNum
=
Yii
::
$app
->
request
->
get
(
$this
->
_page
);
...
...
@@ -104,7 +108,10 @@ class Lists
];
}
}
/**
* @property $spu | String
* 通过spu得到产品评论
*/
public
function
getReviewsBySpu
(
$spu
)
{
$currentIp
=
\
fec\helpers\CFunc
::
get_real_ip
();
...
...
@@ -131,7 +138,7 @@ class Lists
return
Yii
::
$service
->
product
->
review
->
getListBySpu
(
$filter
);
}
// 产品价格信息
protected
function
getProductPriceInfo
(
$product
)
{
$price
=
$product
[
'price'
];
...
...
app/appfront/modules/Catalog/controllers/CategoryController.php
浏览文件 @
9eebf6d0
...
...
@@ -31,7 +31,10 @@ class CategoryController extends AppfrontController
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
}
/**
* Yii2 behaviors 可以参看地址:http://www.yiichina.com/doc/guide/2.0/concept-behaviors
* 这里的行为的作用为添加page cache(整页缓存)。
*/
public
function
behaviors
()
{
$primaryKey
=
Yii
::
$service
->
category
->
getPrimaryKey
();
...
...
app/appfront/modules/Catalog/controllers/FavoriteproductController.php
浏览文件 @
9eebf6d0
...
...
@@ -23,7 +23,7 @@ class FavoriteproductController extends AppfrontController
return
$this
->
getBlock
()
->
getLastData
();
//return $this->render($this->action->id,$data);
}
// 收藏列表
public
function
actionLists
()
{
$data
=
$this
->
getBlock
()
->
getLastData
(
$editForm
);
...
...
app/appfront/modules/Catalog/controllers/ProductController.php
浏览文件 @
9eebf6d0
...
...
@@ -24,7 +24,7 @@ class ProductController extends AppfrontController
Yii
::
$service
->
page
->
theme
->
layoutFile
=
'product_view.php'
;
}
//
网站信息管理
//
产品详细页面
public
function
actionIndex
()
{
//$data = Yii::$service->product->apicoll();
...
...
@@ -34,7 +34,10 @@ class ProductController extends AppfrontController
return
$this
->
render
(
$this
->
action
->
id
,
$data
);
}
/**
* Yii2 behaviors 可以参看地址:http://www.yiichina.com/doc/guide/2.0/concept-behaviors
* 这里的行为的作用为添加page cache(整页缓存)。
*/
public
function
behaviors
()
{
$primaryKey
=
Yii
::
$service
->
product
->
getPrimaryKey
();
...
...
app/apphtml5/modules/Catalog/block/category/Index.php
浏览文件 @
9eebf6d0
...
...
@@ -18,18 +18,31 @@ use yii\base\InvalidValueException;
*/
class
Index
{
// 当前分类对象
protected
$_category
;
// 页面标题
protected
$_title
;
// 当前分类主键对应的值
protected
$_primaryVal
;
// 默认的排序字段
protected
$_defautOrder
;
// 默认的排序方向,升序还是降序
protected
$_defautOrderDirection
=
SORT_DESC
;
// 当前的where条件
protected
$_where
;
// url的参数,每页产品个数
protected
$_numPerPage
=
'numPerPage'
;
// url的参数,排序方向
protected
$_direction
=
'dir'
;
// url的参数,排序字段
protected
$_sort
=
'sort'
;
// url的参数,页数
protected
$_page
=
'p'
;
// url的参数,价格
protected
$_filterPrice
=
'price'
;
// url的参数,价格
protected
$_filterPriceAttr
=
'price'
;
// 产品总数
protected
$_productCount
;
protected
$_filter_attr
;
protected
$_numPerPageVal
;
...
...
@@ -70,7 +83,11 @@ class Index
//'created_at' => $this->_category['created_at'],
];
}
/**
* @property $products | Array 产品的数组。
* ajax方式访问,得到产品的数据
* 这个是wap端手机页面访问,下拉自动加载下一页的数据的加载实现。
*/
protected
function
getAjaxProductHtml
(
$products
)
{
$parentThis
[
'products'
]
=
$products
;
...
...
@@ -95,7 +112,10 @@ class Index
return
$filter_category
;
}
/**
* @property $filter_category | Array
* 通过递归的方式,得到分类以及子分类的html。
*/
protected
function
getFilterCategoryHtml
(
$filter_category
=
''
)
{
$str
=
''
;
...
...
@@ -122,7 +142,10 @@ class Index
//exit;
return
$str
;
}
/**
* 得到产品页面的toolbar部分
* 也就是分类页面的分页工具条部分。
*/
protected
function
getProductPage
()
{
$productNumPerPage
=
$this
->
getNumPerPage
();
...
...
@@ -140,7 +163,10 @@ class Index
return
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_product_page'
,
$config
);
}
/**
* 分类页面toolbar部分:
* 产品排序,产品每页的产品个数等,为这些部分提供数据。
*/
protected
function
getQueryItem
()
{
$category_query
=
Yii
::
$app
->
controller
->
module
->
params
[
'category_query'
];
...
...
@@ -193,7 +219,14 @@ class Index
return
$data
;
}
/**
* @return Array
* 得到当前分类,侧栏用于过滤的属性数组,由三部分计算得出
* 1.全局默认属性过滤(catalog module 配置文件中配置 category_filter_attr),
* 2.当前分类属性过滤,也就是分类表的 filter_product_attr_selected 字段
* 3.当前分类去除的属性过滤,也就是分类表的 filter_product_attr_unselected
* 最终出来一个当前分类,用于过滤的属性数组。
*/
protected
function
getFilterAttr
()
{
if
(
!
$this
->
_filter_attr
)
{
...
...
@@ -209,7 +242,9 @@ class Index
return
$this
->
_filter_attr
;
}
/**
* 得到分类侧栏用于属性过滤的部分数据
*/
protected
function
getRefineByInfo
()
{
$get_arr
=
Yii
::
$app
->
request
->
get
();
...
...
@@ -249,7 +284,9 @@ class Index
return
$refineInfo
;
}
/**
* 侧栏除价格外的其他属性过滤部分
*/
protected
function
getFilterInfo
()
{
$filter_info
=
[];
...
...
@@ -262,7 +299,9 @@ class Index
return
$filter_info
;
}
/**
* 侧栏价格过滤部分
*/
protected
function
getFilterPrice
()
{
$filter
=
[];
...
...
@@ -277,7 +316,9 @@ class Index
return
$filter
;
}
/**
* 格式化价格格式,侧栏价格过滤部分
*/
protected
function
getFormatFilterPrice
(
$price_item
)
{
list
(
$f_price
,
$l_price
)
=
explode
(
'-'
,
$price_item
);
...
...
@@ -293,7 +334,10 @@ class Index
return
$str
;
}
/**
* @property $str | String
* 字符串转换成数组。
*/
protected
function
getFilterArr
(
$str
)
{
$arr
=
[];
...
...
@@ -310,7 +354,9 @@ class Index
return
$arr
;
}
/**
* 用于搜索条件的排序部分
*/
protected
function
getOrderBy
()
{
$primaryKey
=
Yii
::
$service
->
category
->
getPrimaryKey
();
...
...
@@ -345,7 +391,12 @@ class Index
}
}
}
/**
* 分类页面的产品,每页显示的产品个数。
* 对于前端传递的个数参数,在后台验证一下是否是合法的个数(配置里面有一个分类产品个数列表)
* 如果不合法,则报异常
* 这个功能是为了防止分页攻击,伪造大量的不同个数的url,绕过缓存。
*/
protected
function
getNumPerPage
()
{
if
(
!
$this
->
_numPerPageVal
)
{
...
...
@@ -371,14 +422,18 @@ class Index
return
$this
->
_numPerPageVal
;
}
/**
* 得到当前第几页
*/
protected
function
getPageNum
()
{
$numPerPage
=
Yii
::
$app
->
request
->
get
(
$this
->
_page
);
return
$numPerPage
?
(
int
)
$numPerPage
:
1
;
}
/**
* 得到当前分类的产品
*/
protected
function
getCategoryProductColl
()
{
$select
=
[
...
...
@@ -403,7 +458,9 @@ class Index
//var_dump($filter);exit;
return
Yii
::
$service
->
category
->
product
->
getFrontList
(
$filter
);
}
/**
* 得到用于查询的where数组。
*/
protected
function
initWhere
()
{
$filterAttr
=
$this
->
getFilterAttr
();
...
...
@@ -427,7 +484,10 @@ class Index
//var_dump($where);exit;
return
$where
;
}
/**
* 分类部分的初始化
* 对一些属性进行赋值。
*/
protected
function
initCategory
()
{
$primaryKey
=
Yii
::
$service
->
category
->
getPrimaryKey
();
...
...
app/apphtml5/modules/Catalog/block/favoriteproduct/Add.php
浏览文件 @
9eebf6d0
...
...
@@ -17,6 +17,9 @@ use Yii;
*/
class
Add
{
/**
* 用户添加收藏产品
*/
public
function
getLastData
()
{
$product_id
=
Yii
::
$app
->
request
->
get
(
'product_id'
);
...
...
app/apphtml5/modules/Catalog/block/product/CustomOption.php
浏览文件 @
9eebf6d0
...
...
@@ -34,7 +34,9 @@ class CustomOption
'middle_img_width'
=>
$this
->
middle_img_width
,
];
}
/**
* 得到custom option 部分
*/
public
function
getAllItems
()
{
$custom_option_attr_info
=
Yii
::
$service
->
product
->
getCustomOptionAttrInfo
(
$this
->
attr_group
);
...
...
app/apphtml5/modules/Catalog/block/product/Index.php
浏览文件 @
9eebf6d0
...
...
@@ -57,7 +57,7 @@ class Index
];
}
/**
/**
废弃
* @property $data | Array 和当前产品的spu相同,但sku不同的产品 数组。
* @property $current_size | String 当前产品的size值
* @property $current_color | String 当前产品的颜色值
...
...
@@ -121,7 +121,9 @@ class Index
}
/**
* @property $select | Array , 需要查询的字段。
* 得到当前spu下面的所有的sku的数组、
* 这个是为了产品详细页面的spu下面的产品切换,譬如同一spu下的不同的颜色尺码切换。
*/
protected
function
getSpuData
(
$select
)
{
...
...
@@ -141,11 +143,10 @@ class Index
}
/**
* 显示这个的前提是,该产品所在属性组对应的spu_attr 只有color 和size 两种
* 也就是说,这个只针对服装做的一种方式,其他的会按照大众化的那种方式显示出来过滤。(下拉条)
* 这个有点像定制化的范畴,目前我只做了color和size这类
* 衣服类产品需要用到的属性,对于其他的类似属性,就需要自己做定制修改了.
* @return 返回和当前产品spu相同的其他产品,然后以颜色和尺码的方式罗列出来。
* @return Array得到spu下面的sku的spu属性的数据。用于在产品
* 得到spu下面的sku的spu属性的数据。用于在产品详细页面显示其他的sku
* 譬如页面:https://fecshop.appfront.fancyecommerce.com/raglan-sleeves-letter-printed-crew-neck-sweatshirt-53386451-77774122
* 该spu的其他sku的颜色尺码也在这里显示出来。
*/
protected
function
getSameSpuInfo
()
{
...
...
@@ -219,7 +220,7 @@ class Index
return
$spuShowArr
;
}
// spu属性部分
protected
function
getSpuAttrInfo
(
$spuAttr
,
$attrVal
,
$reverse_val_spu
)
{
$current
=
$this
->
_currentSpuAttrValArr
;
...
...
@@ -378,7 +379,7 @@ class Index
Yii
::
$service
->
page
->
breadcrumbs
->
active
=
false
;
}
}
// 买了的人还买了什么,通过产品字段取出来sku,然后查询得到。
protected
function
getProductBySkus
(
$skus
)
{
$buy_also_buy_sku
=
$this
->
_product
[
'buy_also_buy_sku'
];
...
...
app/apphtml5/modules/Catalog/block/product/Review.php
浏览文件 @
9eebf6d0
...
...
@@ -28,7 +28,9 @@ class Review
// 初始化当前apphtml5的设置,覆盖service的初始设置。
ReviewHelper
::
initReviewConfig
();
}
/**
* 得到当前spu下面的所有评论信息。
*/
public
function
getLastData
()
{
if
(
!
$this
->
spu
||
!
$this
->
product_id
)
{
...
...
@@ -48,7 +50,9 @@ class Review
];
}
}
/**
* 得到当前spu下面的所有评论信息。
*/
public
function
getReviewsBySpu
(
$spu
)
{
$review
=
Yii
::
$app
->
getModule
(
'catalog'
)
->
params
[
'review'
];
...
...
app/apphtml5/modules/Catalog/block/reviewproduct/Add.php
浏览文件 @
9eebf6d0
...
...
@@ -24,7 +24,9 @@ class Add
{
ReviewHelper
::
initReviewConfig
();
}
/**
* @return boolean , review页面是否开启验证码验证。
*/
public
function
getAddCaptcha
()
{
if
(
!
$this
->
_add_captcha
)
{
...
...
@@ -77,7 +79,10 @@ class Add
'url'
=>
Yii
::
$service
->
url
->
getUrl
(
$url_key
),
];
}
/**
* @property $editForm | Array
* @return boolean ,保存评论信息
*/
public
function
saveReview
(
$editForm
)
{
$add_captcha
=
$this
->
getAddCaptcha
();
...
...
@@ -85,48 +90,48 @@ class Add
if
(
!
$product_id
)
{
Yii
::
$service
->
page
->
message
->
addError
([
'Product id can not empty'
]);
return
;
return
false
;
}
$rate_star
=
isset
(
$editForm
[
'rate_star'
])
?
$editForm
[
'rate_star'
]
:
''
;
if
(
!
$rate_star
)
{
Yii
::
$service
->
page
->
message
->
addError
([
'Rate Star can not empty'
]);
return
;
return
false
;
}
$name
=
isset
(
$editForm
[
'name'
])
?
$editForm
[
'name'
]
:
''
;
if
(
!
$name
)
{
Yii
::
$service
->
page
->
message
->
addError
([
'Your Name can not empty'
]);
return
;
return
false
;
}
$summary
=
isset
(
$editForm
[
'summary'
])
?
$editForm
[
'summary'
]
:
''
;
if
(
!
$summary
)
{
Yii
::
$service
->
page
->
message
->
addError
([
'Summary can not empty'
]);
return
;
return
false
;
}
$review_content
=
isset
(
$editForm
[
'review_content'
])
?
$editForm
[
'review_content'
]
:
''
;
if
(
!
$review_content
)
{
Yii
::
$service
->
page
->
message
->
addError
([
'Review content can not empty'
]);
return
;
return
false
;
}
// captcha validate
$captcha
=
isset
(
$editForm
[
'captcha'
])
?
$editForm
[
'captcha'
]
:
''
;
if
(
$add_captcha
&&
!
$captcha
)
{
Yii
::
$service
->
page
->
message
->
addError
([
'Captcha can not empty'
]);
return
;
return
false
;
}
elseif
(
$captcha
&&
$add_captcha
&&
!
\
Yii
::
$service
->
helper
->
captcha
->
validateCaptcha
(
$captcha
))
{
Yii
::
$service
->
page
->
message
->
addError
([
'Captcha is not right'
]);
return
;
return
false
;
}
$product
=
Yii
::
$service
->
product
->
getByPrimaryKey
(
$product_id
);
if
(
!
$product
[
'spu'
])
{
Yii
::
$service
->
page
->
message
->
addError
(
'product _id:'
.
$product_id
.
' is not exist in product collection'
);
return
;
return
false
;
}
$editForm
[
'spu'
]
=
$product
[
'spu'
];
$editForm
[
'status'
]
=
$product
[
'spu'
];
...
...
@@ -135,7 +140,10 @@ class Add
return
true
;
}
/**
* @property $product | String Or Object
* 得到产品的价格信息
*/
protected
function
getProductPriceInfo
(
$product
)
{
$price
=
$product
[
'price'
];
...
...
@@ -145,7 +153,7 @@ class Add
return
Yii
::
$service
->
product
->
price
->
getCurrentCurrencyProductPriceInfo
(
$price
,
$special_price
,
$special_from
,
$special_to
);
}
// 废弃
protected
function
getSpuData
()
{
$spu
=
$this
->
_product
[
'spu'
];
...
...
app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php
浏览文件 @
9eebf6d0
...
...
@@ -25,12 +25,16 @@ class Lists
public
$_page
=
'p'
;
public
$numPerPage
=
20
;
public
$pageNum
;
public
function
__construct
()
{
// 初始化服务
ReviewHelper
::
initReviewConfig
();
}
/**
* @property $countTotal | Int
* 得到toolbar的分页部分
*/
protected
function
getProductPage
(
$countTotal
)
{
if
(
$countTotal
<=
$this
->
numPerPage
)
{
...
...
@@ -47,7 +51,7 @@ class Lists
return
Yii
::
$service
->
page
->
widget
->
renderContent
(
'category_product_page'
,
$config
);
}
// 初始化参数
public
function
initParam
()
{
$this
->
pageNum
=
Yii
::
$app
->
request
->
get
(
$this
->
_page
);
...
...
@@ -104,7 +108,10 @@ class Lists
];
}
}
/**
* @property $spu | String
* 通过spu得到产品评论
*/
public
function
getReviewsBySpu
(
$spu
)
{
$currentIp
=
\
fec\helpers\CFunc
::
get_real_ip
();
...
...
@@ -131,7 +138,7 @@ class Lists
return
Yii
::
$service
->
product
->
review
->
getListBySpu
(
$filter
);
}
// 产品价格信息
protected
function
getProductPriceInfo
(
$product
)
{
$price
=
$product
[
'price'
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录