提交 6096b9a9 编写于 作者: R root

增加产品详情页功能:买了这个产品的人还买了什么产品

上级 7ff68629
......@@ -67,6 +67,7 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdi
'custom_option_add' => $this->getCustomOptionAdd(),
'custom_option_img' => $this->getCustomOpImgHtml(),
'custom_option_list' => $this->_custom_option_list_str,
'relation' => $this->getRelationInfo(),
];
}
......@@ -139,6 +140,13 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdi
}
public function getRelationInfo(){
$this->_lang_attr = '';
$this->_textareas = '';
$editArr = $this->_attr->getRelationInfo();
$editBar = $this->getEditBar($editArr);
return $this->_lang_attr.$editBar.$this->_textareas;
}
public function getBaseInfo(){
$this->_lang_attr = '';
......
......@@ -65,6 +65,44 @@ class Attr
}
public function getRelationInfo(){
return [
[
'label'=>'相关产品sku(逗号隔开)',
'name'=>'relation_sku',
'display'=>[
'type' => 'inputString',
],
'require' => 0,
],
[
'label'=>'买了还买sku(逗号隔开)',
'name'=>'buy_also_buy_sku',
'display'=>[
'type' => 'inputString',
],
'require' => 0,
],
[
'label'=>'看了还看sku(逗号隔开)',
'name'=>'see_also_see_sku',
'display'=>[
'type' => 'inputString',
],
'require' => 0,
],
];
}
public function getBaseInfo(){
return [
[
......
......@@ -208,6 +208,7 @@ function thissubmit(thiss){
<li><a href="javascript:;"><span>分类信息</span></a></li>
<li><a href="javascript:;"><span>属性组信息</span></a></li>
<li><a href="javascript:;"><span>自定义信息</span></a></li>
<li><a href="javascript:;"><span>相关产品信息</span></a></li>
</ul>
</div>
</div>
......@@ -479,6 +480,14 @@ function thissubmit(thiss){
});
</script>
</div>
<div class="relation_list" style="margin:20px 2px;">
<?= $relation ?>
</div>
</div>
<div class="tabsFooter">
......
......@@ -51,7 +51,7 @@ class Index {
'custom_option' => $this->_product['custom_option'],
'description' => Yii::$service->store->getStoreAttrVal($this->_product['description'],'description'),
'_id' => $this->_product['_id'],
'buy_also_buy' => $this->getProductBySkus($skus),
];
}
......@@ -275,4 +275,27 @@ class Index {
Yii::$service->page->breadcrumbs->active = false;
}
}
protected function getProductBySkus($skus){
$buy_also_buy_sku = $this->_product['buy_also_buy_sku'];
if($buy_also_buy_sku){
$skus = explode(',',$buy_also_buy_sku);
if(is_array($skus) && !empty($skus)){
$filter['select'] = [
'sku','spu','name','image',
'price','special_price',
'special_from','special_to',
'url_key','score',
];
$filter['where'] = ['in','sku',$skus];
$products = Yii::$service->product->getProducts($filter);
//var_dump($products);
$products = Yii::$service->category->product->convertToCategoryInfo($products);
return $products;
}
}
}
}
......@@ -2344,6 +2344,31 @@ a.next_images {
border: 1px dashed #ccc;
}
#owl-buy-also-buy .pro_img img {
height: 200px;
width: 100%;
}
#owl-buy-also-buy .pro_img a {
display: block;
height: 200px;
padding: 0 7.5px;
width: 180px;
}
.scrollBox #owl-buy-also-buy span.my_shop_price{
font-size:14px;
}
.buy_also_buy{margin:60px 0 0;height:320px;}
.buy_also_buy .scroll_left{margin:15px 0; border-bottom: 1px solid #ccc;}
.buy_also_buy .scrollBox{height:280px;}
......
......@@ -116,7 +116,26 @@
<div class="clear"></div>
</div>
<div>
<?php # tier price 部分。
$buyAlsoBuyView = [
'view' => 'catalog/product/index/buy_also_buy.php'
];
$buyAlsoBuyParam = [
'products' => $buy_also_buy,
];
?>
<?= 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">DESCRIPTION</li>
......@@ -282,4 +301,5 @@
<?php $this->endBlock(); ?>
<?php $this->registerJs($this->blocks['product_info_tab'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</script>
\ No newline at end of file
\ No newline at end of file
<?php if(is_array($parentThis['products']) && !empty($parentThis['products'])){ ?>
<div class="buy_also_buy" >
<div class="scroll_left">
<a href="">Customers Who Bought This Item Also Bought</a>
</div>
<div class="scrollBox">
<div class="viewport" style="overflow: hidden; position: relative;">
<div id="owl-buy-also-buy" class="owl-carousel">
<?php foreach($parentThis['products'] as $product){ ?>
<div class="item">
<p class="tc pro_img">
<a style="" class="i_proImg" href="<?= $product['url'] ?>">
<img style="width:100%;" class="lazyOwl" data-src="<?= Yii::$service->product->image->getResize($product['image'],[180,200],false) ?>" src="<?= Yii::$service->image->getImgUrl('images/lazyload1.gif','appfront') ; ?>">
</a>
</p>
<!--
<p class="proName">
<a href="<?= $product['url'] ?>">
<?= $product['name'] ?>
</a>
</p>
-->
<?php
$config = [
'class' => 'fecshop\app\appfront\modules\Catalog\block\category\Price',
'view' => 'cms/home/index/price.php',
'price' => $product['price'],
'special_price' => $product['special_price'],
];
echo Yii::$service->page->widget->renderContent('category_product_price',$config);
?>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<script>
<?php $this->beginBlock('owl_fecshop_slider') ?>
$(document).ready(function(){
$("#owl-buy-also-buy").owlCarousel({
items : 6,
lazyLoad : true,
navigation : true,
scrollPerPage : true,
pagination:false,
itemsCustom : false,
slideSpeed : 900
});
});
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['owl_fecshop_slider'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
<?php } ?>
......@@ -86,6 +86,9 @@ class Product extends ActiveRecord
'reviw_rate_star_average_lang', #(语言)评论平均评分
'review_count_lang', #(语言)评论总数
'favorite_count', # 产品被收藏的次数。
'relation_sku', # 相关产品
'buy_also_buy_sku', # 买了的还买了什么
'see_also_see_sku', # 看了的还看了什么
];
if(is_array(self::$_customProductAttrs) && !empty(self::$_customProductAttrs)){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册