コード例 #1
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if ($this->context instanceof ModelContextInterface && ($model = $this->context->getModel()) && $model instanceof ProductCategory) {
         $root = $model;
     } else {
         $root = ProductCategory::find()->roots()->active()->one();
     }
     $items = ProductCategory::buildNodeTree($root, $root->children()->active()->all());
     return $this->render('product_categories_list', ['widget' => $this, 'items' => $items]);
 }
コード例 #2
0
ファイル: Product.php プロジェクト: xyxdasnjss/imshop
 public function getCategoriesRelation()
 {
     return $this->hasMany(ProductCategory::className(), ['id' => 'category_id'])->viaTable('{{%products_categories}}', ['product_id' => 'id']);
 }
コード例 #3
0
 /**
  * FiCategory ategory model based on its path.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $path
  * @throws \yii\web\NotFoundHttpException
  * @return ProductCategory the loaded model
  */
 protected function findModel($path)
 {
     if (($model = ProductCategory::findByPath($path)->active()->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
ファイル: Bootstrap.php プロジェクト: xyxdasnjss/imshop
 /**
  * Registers a class definitions in container.
  */
 public function registerDefinitions()
 {
     Yii::$container->set(ProductCategory::className(), ['as seo' => ['class' => 'im\\seo\\components\\SeoBehavior', 'metaClass' => 'im\\catalog\\models\\ProductCategoryMeta', 'ownerType' => false], 'as template' => ['class' => 'im\\cms\\components\\TemplateBehavior']]);
     Yii::$container->set(Product::className(), ['as seo' => ['class' => 'im\\seo\\components\\SeoBehavior', 'metaClass' => 'im\\catalog\\models\\ProductMeta', 'ownerType' => false]]);
 }
コード例 #5
0
 /**
  * @inheritdoc
  */
 protected function getModelClass()
 {
     return ProductCategory::className();
 }