From d3175f4e1ff80c810ab87f935cda0859c59275fd Mon Sep 17 00:00:00 2001 From: Terry <2358269014@qq.com> Date: Fri, 22 Jan 2021 09:30:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=95=8C=E9=9D=A2=EF=BC=8C=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=9B=BE=E7=89=87=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=97=A0=E6=B3=95=E7=82=B9=E5=87=BB=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Catalog/controllers/ProductController.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/appserver/modules/Catalog/controllers/ProductController.php b/app/appserver/modules/Catalog/controllers/ProductController.php index 902a999c9..e72d2a21d 100644 --- a/app/appserver/modules/Catalog/controllers/ProductController.php +++ b/app/appserver/modules/Catalog/controllers/ProductController.php @@ -544,7 +544,10 @@ protected function getSameSpuInfo() } } // 得到当前的spu下面的所有的值 - $select = ['name', 'image', 'url_key']; + $productPrimaryKey = Yii::$service->product->getPrimaryKey(); + $select = [$productPrimaryKey, 'name', 'image', 'url_key']; + + //$select = ['name', 'image', 'url_key']; $data = $this->getSpuData($select); $spuValColl = []; // 通过值,找到spu。 @@ -559,7 +562,7 @@ protected function getSameSpuInfo() //$active = 'class="active"'; $one['main_img'] = isset($one['image']['main']['image']) ? $one['image']['main']['image'] : ''; - $one['url'] = Yii::$service->url->getUrl($one['url_key']); + $one['url'] = '/catalog/product/'.(string)$one[$productPrimaryKey]; $reverse_val_spu[$reverse_key] = $one; $showAsImgVal = $one[$this->_spuAttrShowAsImg]; if ($showAsImgVal) { @@ -588,10 +591,12 @@ protected function getSameSpuInfo() $attr_coll = []; foreach ($attrValArr as $attrVal) { $attr_info = $this->getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu); + $attr_info['attr_val'] = Yii::$service->page->translate->__($attr_info['attr_val']); $attr_coll[] = $attr_info; } $spuShowArr[] = [ - 'label' => $spuAttr, + //'label' => $spuAttr, + 'label' => Yii::$service->page->translate->__($spuAttr), 'value' => $attr_coll, ]; } @@ -621,7 +626,7 @@ protected function getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu) $return[$k] = $v; } if ($spuAttr == $this->_spuAttrShowAsImg) { - $return['show_as_img'] = $arr['main_img']; + $return['show_as_img'] = Yii::$service->product->image->getResize($arr['main_img'],[50,55],false); } } else if ($this->_spuAttrShowAsImg){ // 如果是图片,不存在,则使用备用的。 @@ -633,7 +638,7 @@ protected function getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu) $return[$k] = $v; } } - $return['show_as_img'] = $arr['main_img']; + $return['show_as_img'] = Yii::$service->product->image->getResize($arr['main_img'],[50,55],false); } } else if ($this->_spuAttrShowAsTop){ if ($spuAttr == $this->_spuAttrShowAsTop) { @@ -649,7 +654,9 @@ protected function getSpuAttrInfo($spuAttr, $attrVal, $reverse_val_spu) if ($active) { $return['active'] = 'current'; } - + $productPrimaryKey = Yii::$service->product->getPrimaryKey(); + $return['_id'] = (string)$return[$productPrimaryKey]; + return $return; }