提交 56e90409 编写于 作者: T Terry

产品详细页面,显示产品组属性。

上级 62f1737a
......@@ -42,7 +42,10 @@ class Index
$ReviewAndStarCount = ReviewHelper::getReviewAndStarCount($this->_product);
list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount;
$this->filterProductImg($this->_product['image']);
$groupAttr = Yii::$service->product->getGroupAttr($this->_product['attr_group']);
$groupAttrArr = $this->getGroupAttrArr($groupAttr);
return [
'groupAttrArr' => $groupAttrArr,
'name' => Yii::$service->store->getStoreAttrVal($this->_product['name'], 'name'),
'image_thumbnails' => $this->_image_thumbnails,
'image_detail' => $this->_image_detail,
......@@ -66,6 +69,18 @@ class Index
'buy_also_buy' => $this->getProductBySkus($skus),
];
}
public function getGroupAttrArr($groupAttr){
$gArr = [];
if(is_array($groupAttr)){
foreach($groupAttr as $attr){
if(isset($this->_product[$attr]) && $this->_product[$attr]){
$gArr[$attr] = $this->_product[$attr];
}
}
}
//var_dump($gArr);
return $gArr;
}
/**
* @property $product_images | Array ,产品的图片属性
* 根据图片数组,得到橱窗图,和描述图
......@@ -190,9 +205,10 @@ class Index
*/
protected function getSameSpuInfo()
{
$groupAttr = Yii::$service->product->getGroupAttr($this->_product['attr_group']);
// 当前的产品对应的spu属性组的属性,譬如 ['color','size','myyy']
$this->_productSpuAttrArr = Yii::$service->product->getSpuAttr($this->_product['attr_group']);
//var_dump($this->_productSpuAttrArr);exit;
$this->_spuAttrShowAsImg = Yii::$service->product->getSpuImgAttr($this->_product['attr_group']);
if (!is_array($this->_productSpuAttrArr) || empty($this->_productSpuAttrArr)) {
return;
......
......@@ -138,15 +138,10 @@
];
?>
<?= Yii::$service->page->widget->render($buyAlsoBuyView,$buyAlsoBuyParam); ?>
</div>
<div class="clear"></div>
<div class="product_description_info">
<div class="nav" id="nav-container">
<ul id="nav-box">
<li class="nav_tab cur" rel="description"><?= Yii::$service->page->translate->__('Description'); ?></li>
......@@ -157,6 +152,15 @@
</div>
<div id="text">
<div class="text-description" style="">
<?php if(is_array($groupAttrArr)): ?>
<table>
<?php foreach($groupAttrArr as $k => $v): ?>
<tr><td><?= $k ?></td><td><?= $v ?></td></tr>
<?php endforeach; ?>
</table>
<br/>
<?php endif; ?>
<?= $description; ?>
<div class="img-section">
......@@ -383,7 +387,7 @@
interval = setInterval(function(){
if(scroll.scrollTop + a<=textChild[self.index].offsetTop){
scroll.scrollTop += 40;
scroll.scrollTop += 1500;
if(scroll.scrollTop + a>=textChild[self.index].offsetTop){
scroll.scrollTop = textChild[self.index].offsetTop-a;
clearInterval(interval);
......@@ -395,7 +399,7 @@
clearInterval(interval);
}
}
},40);
},4);
};
}
<?php $this->endBlock(); ?>
......
......@@ -48,7 +48,7 @@ class Product extends Service
/**
* @property $productAttrGroup|string
* 得到这个产品属性组里面的所有的产品属性,
* 得到这个产品属性组里面的所有的产品属性详细
* 注解:不同类型的产品,对应不同的属性组,譬如衣服有颜色尺码,电脑类型的有不同cpu型号等
* 属性组,以及属性组对应的属性,是在Product Service config中配置的。
*/
......@@ -70,10 +70,46 @@ class Product extends Service
) {
$arr = array_merge($arr, $this->customAttrGroup[$productAttrGroup]['spu_attr']);
}
//var_dump($arr);
return $arr;
}
/**
* @property $productAttrGroup|string
* 得到这个产品属性组里面的所有的产品属性,
* 注解:不同类型的产品,对应不同的属性组,譬如衣服有颜色尺码,电脑类型的有不同cpu型号等
* 属性组,以及属性组对应的属性,是在Product Service config中配置的。
*/
protected function actionGetGroupAttr($productAttrGroup)
{
$arr = [];
// 得到普通属性
if (isset($this->customAttrGroup[$productAttrGroup]['general_attr'])
&& is_array($this->customAttrGroup[$productAttrGroup]['general_attr'])
) {
$general_attr = $this->customAttrGroup[$productAttrGroup]['general_attr'];
if(is_array($general_attr)){
foreach($general_attr as $attr => $info){
$arr[] = $attr;
}
}
}
// 得到用于spu,细分sku的属性,譬如颜色尺码之类。
if (isset($this->customAttrGroup[$productAttrGroup]['spu_attr'])
&& is_array($this->customAttrGroup[$productAttrGroup]['spu_attr'])
) {
$spu_attr = $this->customAttrGroup[$productAttrGroup]['spu_attr'];
if(is_array($spu_attr)){
foreach($spu_attr as $attr => $info){
$arr[] = $attr;
}
}
}
//var_dump($arr);
return $arr;
}
/**
* @property $productAttrGroup|string
* @return 一维数组
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册