提交 193f9f9c 编写于 作者: T Terry

appserver product custom option

上级 ba52526e
......@@ -62,7 +62,10 @@ class ProductController extends AppserverController
$this->filterProductImg($this->_product['image']);
$groupAttr = Yii::$service->product->getGroupAttr($this->_product['attr_group']);
$groupAttrArr = $this->getGroupAttrArr($groupAttr);
$custom_option_attr_info = Yii::$service->product->getCustomOptionAttrInfo($this->_product['attr_group']);
//var_dump($custom_option_attr_info);exit;
$custom_option_showImg_attr = $this->getCustomOptionShowImgAttr($custom_option_attr_info);
//var_dump($custom_option_showImg_attr );exit;
$thumbnail_img = [];
$image = $this->_image_thumbnails;
if(isset($image['gallery']) && is_array($image['gallery']) && !empty($image['gallery'])){
......@@ -83,7 +86,7 @@ class ProductController extends AppserverController
$thumbnail_img[] = Yii::$service->product->image->getResize($image,$middle_img_width,false);
}
}
$custom_option = $this->getCustomOption($this->_product['custom_option'],$middle_img_width);
return [
'code' => 200,
'content' =>[
......@@ -92,7 +95,8 @@ class ProductController extends AppserverController
'sku' => $this->_product['sku'],
'spu' => $this->_product['spu'],
'thumbnail_img' => $thumbnail_img,
'groupAttrArr' => $groupAttrArr,
'custom_option_showImg_attr'=> $custom_option_showImg_attr,
//'groupAttrArr' => $groupAttrArr,
//'image_thumbnails' => $this->_image_thumbnails,
'image_detail' => $this->_image_detail,
'attr_group' => $this->_product['attr_group'],
......@@ -107,7 +111,7 @@ class ProductController extends AppserverController
//],
//'productImgMagnifier' => $productImgMagnifier,
'options' => $this->getSameSpuInfo(),
'custom_option' => $this->_product['custom_option'],
'custom_option' => $custom_option,
'description' => Yii::$service->store->getStoreAttrVal($this->_product['description'], 'description'),
'_id' => $this->_product['_id'],
'buy_also_buy' => $this->getProductBySkus($skus),
......@@ -115,6 +119,29 @@ class ProductController extends AppserverController
]
];
}
public function getCustomOptionShowImgAttr($custom_option_attr_info){
foreach($custom_option_attr_info as $attr => $one){
if($one['showAsImg']){
return $attr;
}
}
}
public function getCustomOption($custom_option,$middle_img_width){
$arr = [];
if(is_array($custom_option)){
foreach($custom_option as $attr => $one){
if($attr && isset($one['image']) && $one['image']){
$one['image'] = Yii::$service->product->image->getResize($one['image'],[40,45],false);
$arr[$attr] = $one;
}
}
}
return $arr;
}
public function getGroupAttrArr($groupAttr){
$gArr = [];
if(is_array($groupAttr)){
......
......@@ -74,9 +74,7 @@ class Product extends Service
$coll = Yii::$service->product->getFrontCategoryProducts($filter);
$collection = $coll['coll'];
$count = $coll['count'];
$arr = $this->convertToCategoryInfo($collection);
return [
'coll' => $arr,
'count'=> $count,
......
......@@ -553,9 +553,12 @@ class ProductMongodb implements ProductInterface
}
$group['product_id'] = ['$first' => '$product_id'];
$langCode = Yii::$service->store->currentLangCode;
$name_lang = Yii::$service->fecshoplang->getLangAttrName('name',$langCode);
$default_name_lang = Yii::$service->fecshoplang->GetDefaultLangAttrName('name');
$project['name'] = [
$name_lang => 1
$default_name_lang => 1,
$name_lang => 1,
];
$project['product_id'] = '$_id';
$pipelines = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册