diff --git a/common/models/Product.php b/common/models/Product.php new file mode 100644 index 0000000..87a06ee --- /dev/null +++ b/common/models/Product.php @@ -0,0 +1,60 @@ + [ + 'class' => LanguageBehavior::className(), + ], + 'timestamp' => [ + 'class' => TimestampBehavior::className(), + ], + [ + 'class' => ManyToManyBehavior::className(), + ], + [ + 'class' => BitMaskBehavior::className(), + 'fields' => [ + 'top' => 0, + 'new' => 1, + 'akcia' => 2, + 'exclusive' => 3, + ], + ], + [ + 'class' => GalleryBehavior::className(), + ], + ]; + } + public function getImages() + { + $ids = []; + $gallery = $this->gallery; + if (!empty($gallery)) { + $ids = array_filter(json_decode($gallery)); + } + if (!empty($this->image_id)) { + $ids[] = $this->image_id; + } + $this->imgIds = $ids; + return $this->hasMany(Image::className(), [ 'id' => 'imgIds' ]); + } + } \ No newline at end of file diff --git a/common/models/ProductLang.php b/common/models/ProductLang.php new file mode 100644 index 0000000..7a2a6b3 --- /dev/null +++ b/common/models/ProductLang.php @@ -0,0 +1,14 @@ +hasOne(Product::className(), [ 'id' => 'product_id' ]) + ->inverseOf('variants'); + } + } \ No newline at end of file diff --git a/common/models/VariantLang.php b/common/models/VariantLang.php new file mode 100644 index 0000000..4d17d75 --- /dev/null +++ b/common/models/VariantLang.php @@ -0,0 +1,14 @@ +addColumn('product', 'gallery', $this->string()); + } + + public function safeDown() + { + $this->dropColumn('product', 'gallery'); + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m170920_154718_add_column_gallery_to_product_table cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/frontend/config/main.php b/frontend/config/main.php index f2d4d3a..297cad8 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -57,6 +57,11 @@ 'class' => SeoUrlManager::className(), 'enablePrettyUrl' => true, 'showScriptName' => false, + 'processRoutes' => [ + 'variant/view', + 'product/view', + 'blog/article' + ], 'rules' => [ [ 'pattern' => 'filter/', diff --git a/frontend/controllers/VariantController.php b/frontend/controllers/VariantController.php index 500e7fb..4a5e3fe 100755 --- a/frontend/controllers/VariantController.php +++ b/frontend/controllers/VariantController.php @@ -2,7 +2,7 @@ namespace frontend\controllers; - use artbox\catalog\models\Variant; + use common\models\Variant; use artbox\core\components\SeoComponent; use yii\db\ActiveQuery; use yii\web\Controller; -- libgit2 0.21.4