Compare View
Commits (2)
Showing
1 changed file
Show diff stats
common/modules/product/helpers/ProductHelper.php
| @@ -108,10 +108,16 @@ class ProductHelper extends Object { | @@ -108,10 +108,16 @@ class ProductHelper extends Object { | ||
| 108 | if (!$product->properties) { | 108 | if (!$product->properties) { |
| 109 | return []; | 109 | return []; |
| 110 | } | 110 | } |
| 111 | + $product_categories = []; | ||
| 112 | + foreach ($product->categories as $category) { | ||
| 113 | + $product_categories[] = $category->category_id; | ||
| 114 | + } | ||
| 111 | $query = Product::find() | 115 | $query = Product::find() |
| 112 | ->select('product.product_id') | 116 | ->select('product.product_id') |
| 113 | ->innerJoinWith('variant') | 117 | ->innerJoinWith('variant') |
| 114 | - ->where(['!=', 'product_variant.stock', 0]); | 118 | + ->joinWith('category') |
| 119 | + ->where(['!=', 'product_variant.stock', 0]) | ||
| 120 | + ->andWhere(['product_category.category_id' => $product_categories]); | ||
| 115 | // $query->andWhere(['>=', 'product_variant.price', $product->enabledVariant->price * 0.7]); | 121 | // $query->andWhere(['>=', 'product_variant.price', $product->enabledVariant->price * 0.7]); |
| 116 | // $query->andWhere(['<=', 'product_variant.price', $product->enabledVariant->price * 1.3]); | 122 | // $query->andWhere(['<=', 'product_variant.price', $product->enabledVariant->price * 1.3]); |
| 117 | foreach($product->properties as $group) { | 123 | foreach($product->properties as $group) { |