Пример #1
0
 private function findCategoryBySeoUrl($seoUrl, $parentId, $options = [])
 {
     $categoriesSeoData = SeoData::find()->where(['entity_name' => CategoryTranslation::className(), 'seo_url' => $seoUrl])->all();
     if ($categoriesSeoData) {
         foreach ($categoriesSeoData as $categorySeoData) {
             if ($category = Category::find()->joinWith('translations translation')->where(array_merge(['translation.id' => $categorySeoData->entity_id, 'parent_id' => $parentId, 'translation.language_id' => $this->currentLanguage->id], $options))->one()) {
                 return $category;
             }
         }
     }
     return null;
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTranslations()
 {
     return $this->hasMany(CategoryTranslation::className(), ['category_id' => 'id']);
 }