From 14a26e7259b9f1f5c2ffda251e2d0dc5986cc016 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 10 Mar 2017 11:55:57 +0200 Subject: [PATCH] -Empty enabled variant in similar --- common/modules/product/helpers/ProductHelper.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/modules/product/helpers/ProductHelper.php b/common/modules/product/helpers/ProductHelper.php index 9736988..4a1a1a6 100755 --- a/common/modules/product/helpers/ProductHelper.php +++ b/common/modules/product/helpers/ProductHelper.php @@ -132,7 +132,10 @@ if(!is_object($product)) { $product = Product::find() ->where([ 'product_id' => $product ]) - ->with('enabledVariants') + ->with([ + 'enabledVariants', + 'variant', + ]) ->one(); } @@ -153,8 +156,8 @@ 1, ]) ->andWhere([ 'product_category.category_id' => $product_categories ]); - $query->andWhere(['>=', 'product_variant.price', $product->enabledVariant->price * 0.7]); - $query->andWhere(['<=', 'product_variant.price', $product->enabledVariant->price * 1.3]); + $query->andWhere(['>=', 'product_variant.price', $product->variant->price * 0.7]); + $query->andWhere(['<=', 'product_variant.price', $product->variant->price * 1.3]); $query->innerJoin('product_option', 'product_option.product_id = product.product_id'); $where = [ ]; @@ -192,7 +195,6 @@ /** * @param ActiveQuery $query * @param $params - * @param bool $setPriceLimits */ public static function _setQueryParams(&$query, $params) { -- libgit2 0.21.4