Beispiel #1
0
 private function findProductBySeoUrl($seoUrl, $categoryId, $options = [])
 {
     $productsSeoData = SeoData::find()->where(['entity_name' => ProductTranslation::className(), 'seo_url' => $seoUrl])->all();
     if ($productsSeoData) {
         foreach ($productsSeoData as $productSeoData) {
             if ($product = Product::find()->joinWith('translations translation')->where(array_merge(['translation.id' => $productSeoData->entity_id, 'category_id' => $categoryId, 'translation.language_id' => $this->currentLanguage->id], $options))->one()) {
                 return $product;
             }
         }
     }
     return null;
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTranslations()
 {
     return $this->hasMany(ProductTranslation::className(), ['product_id' => 'id']);
 }