|
@@ -955,6 +955,8 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
$whereArr = [
|
|
|
['in', 'id', $productIds]
|
|
|
];
|
|
|
+ $appName = Yii::$service->helper->getAppName();
|
|
|
+ $category_query_priceRange = Yii::$app->store->get($appName.'_catalog','category_filter_attr');
|
|
|
foreach ($where as $k=>$v) {
|
|
|
if ($k == 'price' && is_array($v)) { // 价格数据处理。
|
|
|
foreach ($v as $k1=>$v1) {
|
|
@@ -965,7 +967,7 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
if ($k1 == '$lt') $fh = '<' ;
|
|
|
$whereArr[] = [$fh, 'price', $v1];
|
|
|
}
|
|
|
- }elseif( $k == 'color' ){
|
|
|
+ }elseif( strpos($category_query_priceRange,$k) !== FALSE ){
|
|
|
$whereArr[] = ['like','attr_group_info',$v];
|
|
|
} else {
|
|
|
$whereArr[] = [$k =>$v];
|
|
@@ -1040,8 +1042,7 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
['in', 'id', $productIds]
|
|
|
];
|
|
|
$appName = Yii::$service->helper->getAppName();
|
|
|
- $category_query_priceRange = Yii::$app->store->get($appName.'_catalog','category_query_priceRange');
|
|
|
- //print_r($ca)
|
|
|
+ $category_query_priceRange = Yii::$app->store->get($appName.'_catalog','category_filter_attr');
|
|
|
foreach ($where as $k=>$v) {
|
|
|
if ($k == 'price' && is_array($v)) { // 价格数据处理。
|
|
|
foreach ($v as $k1=>$v1) {
|
|
@@ -1052,7 +1053,7 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
if ($k1 == '$lt') $fh = '<' ;
|
|
|
$whereArr[] = [$fh, 'price', $v1];
|
|
|
}
|
|
|
- }elseif( strpos('colorsize',$k) !== FALSE ){
|
|
|
+ }elseif( strpos($category_query_priceRange,$k) !== FALSE ){
|
|
|
$whereArr[] = ['like','attr_group_info',$v];
|
|
|
} else {
|
|
|
$whereArr[] = [$k =>$v];
|
|
@@ -1116,12 +1117,16 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
$where['status'] = $this->getEnableStatus();
|
|
|
}
|
|
|
|
|
|
- if($filter_attr != 'color'){
|
|
|
+ $appName = Yii::$service->helper->getAppName();
|
|
|
+ $category_query_priceRange = Yii::$app->store->get($appName.'_catalog','category_filter_attr');
|
|
|
+
|
|
|
+ if(strpos("0".$category_query_priceRange,$filter_attr) == FALSE ){
|
|
|
+
|
|
|
if (!$this->_productModel->hasAttribute($filter_attr)) {
|
|
|
return [];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ //print_r($filter_attr);exit;
|
|
|
// where条件处理
|
|
|
if ($categoryId = $where['category']) {
|
|
|
$productIds = $this->getProductIdsByCategoryId($categoryId);
|
|
@@ -1132,7 +1137,7 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
['in', 'id', $productIds]
|
|
|
];
|
|
|
foreach ($where as $k=>$v) {
|
|
|
- if($k == 'color'){
|
|
|
+ if(strpos($category_query_priceRange,$k) !== FALSE ){
|
|
|
$whereArr[] = ['like','attr_group_info',$v];
|
|
|
}else{
|
|
|
$whereArr[] = [$k =>$v];
|
|
@@ -1151,11 +1156,11 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
|
|
|
foreach ($product_attrs as $key => $value) {
|
|
|
$product_attr = unserialize($value['attr_group_info']);
|
|
|
- if(isset($product_attr['color'])){
|
|
|
- if(isset($filter_attr_array[$product_attr['color']])){
|
|
|
- $filter_attr_array[$product_attr['color']] += 1;
|
|
|
+ if(isset($product_attr[$filter_attr])){
|
|
|
+ if(isset($filter_attr_array[$product_attr[$filter_attr]])){
|
|
|
+ $filter_attr_array[$product_attr[$filter_attr]] += 1;
|
|
|
}else{
|
|
|
- $filter_attr_array[$product_attr['color']] = 1;
|
|
|
+ $filter_attr_array[$product_attr[$filter_attr]] = 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1177,7 +1182,7 @@ class ProductMysqldb extends Service implements ProductInterface
|
|
|
// ->where($where)
|
|
|
// ->groupBy($filter_attr)
|
|
|
// ->all();
|
|
|
-
|
|
|
+
|
|
|
return $filter_data;
|
|
|
}
|
|
|
|