Commit a22144fac44fab81d54532801cc8641a7fd49db9
1 parent
8a7d402e
20.07.16
Showing
2 changed files
with
26 additions
and
26 deletions
Show diff stats
common/modules/product/helpers/ProductHelper.php
1 | <?php | 1 | <?php |
2 | - | 2 | + |
3 | namespace common\modules\product\helpers; | 3 | namespace common\modules\product\helpers; |
4 | - | 4 | + |
5 | use common\modules\product\models\Brand; | 5 | use common\modules\product\models\Brand; |
6 | use common\modules\product\models\Category; | 6 | use common\modules\product\models\Category; |
7 | use common\modules\product\models\Product; | 7 | use common\modules\product\models\Product; |
@@ -11,28 +11,28 @@ | @@ -11,28 +11,28 @@ | ||
11 | use yii\base\Object; | 11 | use yii\base\Object; |
12 | use Yii; | 12 | use Yii; |
13 | use yii\db\ActiveQuery; | 13 | use yii\db\ActiveQuery; |
14 | - | 14 | + |
15 | class ProductHelper extends Object | 15 | class ProductHelper extends Object |
16 | { | 16 | { |
17 | - | 17 | + |
18 | const PRODUCT_TAX_GROUP_ID_TARGET = 20; | 18 | const PRODUCT_TAX_GROUP_ID_TARGET = 20; |
19 | const PRODUCT_TAX_GROUP_ID_YEAR = 21; | 19 | const PRODUCT_TAX_GROUP_ID_YEAR = 21; |
20 | const PRODUCT_TAX_GROUP_ID_SEX = 22; | 20 | const PRODUCT_TAX_GROUP_ID_SEX = 22; |
21 | - | 21 | + |
22 | const PRODUCT_VARIANT_TYPE_COLOR = 1; | 22 | const PRODUCT_VARIANT_TYPE_COLOR = 1; |
23 | const PRODUCT_VARIANT_TYPE_SIZE = 2; | 23 | const PRODUCT_VARIANT_TYPE_SIZE = 2; |
24 | - | 24 | + |
25 | public static function getCategories() | 25 | public static function getCategories() |
26 | { | 26 | { |
27 | return Category::find() | 27 | return Category::find() |
28 | ->getTree(); // with('categoryName')-> | 28 | ->getTree(); // with('categoryName')-> |
29 | } | 29 | } |
30 | - | 30 | + |
31 | public static function getBrands() | 31 | public static function getBrands() |
32 | { | 32 | { |
33 | return Brand::find(); // ->with('brandName') | 33 | return Brand::find(); // ->with('brandName') |
34 | } | 34 | } |
35 | - | 35 | + |
36 | /* | 36 | /* |
37 | * Return custom filter-option link | 37 | * Return custom filter-option link |
38 | * @var array $filter | 38 | * @var array $filter |
@@ -74,7 +74,7 @@ | @@ -74,7 +74,7 @@ | ||
74 | } | 74 | } |
75 | return $result; | 75 | return $result; |
76 | } | 76 | } |
77 | - | 77 | + |
78 | public static function addLastProsucts($product_id) | 78 | public static function addLastProsucts($product_id) |
79 | { | 79 | { |
80 | $last_products = self::getLastProducts(); | 80 | $last_products = self::getLastProducts(); |
@@ -86,7 +86,7 @@ | @@ -86,7 +86,7 @@ | ||
86 | Yii::$app->session->set('last_products', $last_products); | 86 | Yii::$app->session->set('last_products', $last_products); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | - | 89 | + |
90 | public static function getLastProducts($as_object = false) | 90 | public static function getLastProducts($as_object = false) |
91 | { | 91 | { |
92 | $last_products = Yii::$app->session->get('last_products', [ ]); | 92 | $last_products = Yii::$app->session->get('last_products', [ ]); |
@@ -103,7 +103,7 @@ | @@ -103,7 +103,7 @@ | ||
103 | } | 103 | } |
104 | return array_reverse($last_products); | 104 | return array_reverse($last_products); |
105 | } | 105 | } |
106 | - | 106 | + |
107 | public static function getSpecialProducts($type, $count, $sort = NULL) | 107 | public static function getSpecialProducts($type, $count, $sort = NULL) |
108 | { | 108 | { |
109 | switch($type) { | 109 | switch($type) { |
@@ -128,7 +128,7 @@ | @@ -128,7 +128,7 @@ | ||
128 | ->limit($count)/*->orderBy($sort)*/ | 128 | ->limit($count)/*->orderBy($sort)*/ |
129 | ->all(); | 129 | ->all(); |
130 | } | 130 | } |
131 | - | 131 | + |
132 | public static function getSimilarProducts($product, $count = 10) | 132 | public static function getSimilarProducts($product, $count = 10) |
133 | { | 133 | { |
134 | if(!is_object($product)) { | 134 | if(!is_object($product)) { |
@@ -137,7 +137,7 @@ | @@ -137,7 +137,7 @@ | ||
137 | ->with('enabledVariants') | 137 | ->with('enabledVariants') |
138 | ->one(); | 138 | ->one(); |
139 | } | 139 | } |
140 | - | 140 | + |
141 | if(!$product->properties) { | 141 | if(!$product->properties) { |
142 | return [ ]; | 142 | return [ ]; |
143 | } | 143 | } |
@@ -182,7 +182,7 @@ | @@ -182,7 +182,7 @@ | ||
182 | } | 182 | } |
183 | return $products; | 183 | return $products; |
184 | } | 184 | } |
185 | - | 185 | + |
186 | /** | 186 | /** |
187 | * @param ActiveQuery $query | 187 | * @param ActiveQuery $query |
188 | * @param $params | 188 | * @param $params |
@@ -217,9 +217,9 @@ | @@ -217,9 +217,9 @@ | ||
217 | ]); | 217 | ]); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | - | 220 | + |
221 | foreach($params as $key => $param) { | 221 | foreach($params as $key => $param) { |
222 | - | 222 | + |
223 | switch($key) { | 223 | switch($key) { |
224 | case 'special': | 224 | case 'special': |
225 | foreach($param as $key => $value) { | 225 | foreach($param as $key => $value) { |
@@ -249,7 +249,7 @@ | @@ -249,7 +249,7 @@ | ||
249 | break; | 249 | break; |
250 | default: | 250 | default: |
251 | $query->andWhere( | 251 | $query->andWhere( |
252 | - Product::tableName() . '.product_id IN ( | 252 | + Product::tableName() . '.product_id IN ( |
253 | SELECT DISTINCT products | 253 | SELECT DISTINCT products |
254 | FROM ( | 254 | FROM ( |
255 | SELECT product_id AS products | 255 | SELECT product_id AS products |
@@ -263,16 +263,16 @@ | @@ -263,16 +263,16 @@ | ||
263 | INNER JOIN tax_option ON tax_option.tax_option_id = product_variant_option.option_id | 263 | INNER JOIN tax_option ON tax_option.tax_option_id = product_variant_option.option_id |
264 | INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id | 264 | INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id |
265 | WHERE tax_group.alias LIKE \''. $key .'\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\')) | 265 | WHERE tax_group.alias LIKE \''. $key .'\' AND tax_option.alias IN (\'' . implode('\',\'', $param) . '\')) |
266 | - ) | ||
267 | - ) AS table_name | 266 | + ) |
267 | + ) AS table_name | ||
268 | )' | 268 | )' |
269 | ); | 269 | ); |
270 | } | 270 | } |
271 | - | 271 | + |
272 | } | 272 | } |
273 | - | 273 | + |
274 | } | 274 | } |
275 | - | 275 | + |
276 | public static function productCountQuery($category = NULL, $params, $excludeKeys = [ ]) | 276 | public static function productCountQuery($category = NULL, $params, $excludeKeys = [ ]) |
277 | { | 277 | { |
278 | $p = [ ]; | 278 | $p = [ ]; |
@@ -289,14 +289,14 @@ | @@ -289,14 +289,14 @@ | ||
289 | } | 289 | } |
290 | ProductHelper::_setQueryParams($query, $params); | 290 | ProductHelper::_setQueryParams($query, $params); |
291 | $query->select([ 'COUNT(product.product_id)' ]); | 291 | $query->select([ 'COUNT(product.product_id)' ]); |
292 | - | 292 | + |
293 | return $query; | 293 | return $query; |
294 | } | 294 | } |
295 | - | 295 | + |
296 | public static function addLastCategory($category_id) { | 296 | public static function addLastCategory($category_id) { |
297 | \Yii::$app->session->set('last_category_id', $category_id); | 297 | \Yii::$app->session->set('last_category_id', $category_id); |
298 | } | 298 | } |
299 | - | 299 | + |
300 | public static function getLastCategory() { | 300 | public static function getLastCategory() { |
301 | return \Yii::$app->session->get('last_category_id'); | 301 | return \Yii::$app->session->get('last_category_id'); |
302 | } | 302 | } |
common/modules/product/widgets/specialProducts.php
@@ -10,7 +10,7 @@ use Yii; | @@ -10,7 +10,7 @@ use Yii; | ||
10 | class specialProducts extends Widget { | 10 | class specialProducts extends Widget { |
11 | public $type = 'top'; | 11 | public $type = 'top'; |
12 | 12 | ||
13 | - public $count = 8; | 13 | + public $count = 15; |
14 | 14 | ||
15 | public $sort = 'default'; | 15 | public $sort = 'default'; |
16 | 16 |