Commit c4420ba8df08cdc8b5938eaf3520698cad394f0a
Merge remote-tracking branch 'origin/vetal' into vetal
Showing
7 changed files
with
143 additions
and
1 deletions
Show diff stats
1 | +<?php | ||
2 | + /** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: stes | ||
5 | + * Date: 20.09.17 | ||
6 | + * Time: 18:52 | ||
7 | + */ | ||
8 | + | ||
9 | + namespace common\models; | ||
10 | + | ||
11 | + use artbox\core\behaviors\BitMaskBehavior; | ||
12 | + use artbox\core\behaviors\GalleryBehavior; | ||
13 | + use artbox\core\behaviors\LanguageBehavior; | ||
14 | + use artbox\core\behaviors\ManyToManyBehavior; | ||
15 | + use artbox\core\models\Image; | ||
16 | + use yii\behaviors\TimestampBehavior; | ||
17 | + | ||
18 | + class Product extends \artbox\catalog\models\Product | ||
19 | + { | ||
20 | + public $imgIds; | ||
21 | + public function behaviors() | ||
22 | + { | ||
23 | + return [ | ||
24 | + 'language' => [ | ||
25 | + 'class' => LanguageBehavior::className(), | ||
26 | + ], | ||
27 | + 'timestamp' => [ | ||
28 | + 'class' => TimestampBehavior::className(), | ||
29 | + ], | ||
30 | + [ | ||
31 | + 'class' => ManyToManyBehavior::className(), | ||
32 | + ], | ||
33 | + [ | ||
34 | + 'class' => BitMaskBehavior::className(), | ||
35 | + 'fields' => [ | ||
36 | + 'top' => 0, | ||
37 | + 'new' => 1, | ||
38 | + 'akcia' => 2, | ||
39 | + 'exclusive' => 3, | ||
40 | + ], | ||
41 | + ], | ||
42 | + [ | ||
43 | + 'class' => GalleryBehavior::className(), | ||
44 | + ], | ||
45 | + ]; | ||
46 | + } | ||
47 | + public function getImages() | ||
48 | + { | ||
49 | + $ids = []; | ||
50 | + $gallery = $this->gallery; | ||
51 | + if (!empty($gallery)) { | ||
52 | + $ids = array_filter(json_decode($gallery)); | ||
53 | + } | ||
54 | + if (!empty($this->image_id)) { | ||
55 | + $ids[] = $this->image_id; | ||
56 | + } | ||
57 | + $this->imgIds = $ids; | ||
58 | + return $this->hasMany(Image::className(), [ 'id' => 'imgIds' ]); | ||
59 | + } | ||
60 | + } | ||
0 | \ No newline at end of file | 61 | \ No newline at end of file |
1 | +<?php | ||
2 | + /** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: stes | ||
5 | + * Date: 20.09.17 | ||
6 | + * Time: 18:53 | ||
7 | + */ | ||
8 | + | ||
9 | + namespace common\models; | ||
10 | + | ||
11 | + class Variant extends \artbox\catalog\models\Variant | ||
12 | + { | ||
13 | + public function getProduct() | ||
14 | + { | ||
15 | + return $this->hasOne(Product::className(), [ 'id' => 'product_id' ]) | ||
16 | + ->inverseOf('variants'); | ||
17 | + } | ||
18 | + } | ||
0 | \ No newline at end of file | 19 | \ No newline at end of file |
console/migrations/m170920_154718_add_column_gallery_to_product_table.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use yii\db\Migration; | ||
4 | + | ||
5 | +class m170920_154718_add_column_gallery_to_product_table extends Migration | ||
6 | +{ | ||
7 | + public function safeUp() | ||
8 | + { | ||
9 | + $this->addColumn('product', 'gallery', $this->string()); | ||
10 | + } | ||
11 | + | ||
12 | + public function safeDown() | ||
13 | + { | ||
14 | + $this->dropColumn('product', 'gallery'); | ||
15 | + } | ||
16 | + | ||
17 | + /* | ||
18 | + // Use up()/down() to run migration code without a transaction. | ||
19 | + public function up() | ||
20 | + { | ||
21 | + | ||
22 | + } | ||
23 | + | ||
24 | + public function down() | ||
25 | + { | ||
26 | + echo "m170920_154718_add_column_gallery_to_product_table cannot be reverted.\n"; | ||
27 | + | ||
28 | + return false; | ||
29 | + } | ||
30 | + */ | ||
31 | +} |
frontend/config/main.php
@@ -57,6 +57,11 @@ | @@ -57,6 +57,11 @@ | ||
57 | 'class' => SeoUrlManager::className(), | 57 | 'class' => SeoUrlManager::className(), |
58 | 'enablePrettyUrl' => true, | 58 | 'enablePrettyUrl' => true, |
59 | 'showScriptName' => false, | 59 | 'showScriptName' => false, |
60 | + 'processRoutes' => [ | ||
61 | + 'variant/view', | ||
62 | + 'product/view', | ||
63 | + 'blog/article' | ||
64 | + ], | ||
60 | 'rules' => [ | 65 | 'rules' => [ |
61 | [ | 66 | [ |
62 | 'pattern' => 'filter/<filter>', | 67 | 'pattern' => 'filter/<filter>', |
frontend/controllers/VariantController.php
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | 2 | ||
3 | namespace frontend\controllers; | 3 | namespace frontend\controllers; |
4 | 4 | ||
5 | - use artbox\catalog\models\Variant; | 5 | + use common\models\Variant; |
6 | use artbox\core\components\SeoComponent; | 6 | use artbox\core\components\SeoComponent; |
7 | use yii\db\ActiveQuery; | 7 | use yii\db\ActiveQuery; |
8 | use yii\web\Controller; | 8 | use yii\web\Controller; |