From 76f5d86fdf6dd381fb17cfa146fcaa474f62b176 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 2 Dec 2016 13:39:05 +0200 Subject: [PATCH] add variantSku --- widgets/Seo.php | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/widgets/Seo.php b/widgets/Seo.php index b6f846c..9406a2f 100755 --- a/widgets/Seo.php +++ b/widgets/Seo.php @@ -23,10 +23,6 @@ class Seo extends Widget public $key; public $name; public $project_name; - public $widgetData; - - public $widgetDynamicData; - public static $optionsListObject; public static $optionsList; protected static $check_url; protected static $check_url_bool; @@ -41,16 +37,9 @@ class Seo extends Widget public function init() { $this->url = \Yii::$app->request->url; - $this->project_name = \Yii::$app->name; - - $this->widgetData = static::findSeoByUrl($this->url); - - $this->widgetDynamicData = $this->findSeoByDynamic(); - if(empty(self::$optionsList)){ - self::$optionsListObject = TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(); - self::$optionsList = ArrayHelper::getColumn(self::$optionsListObject,'lang.alias'); + self::$optionsList = ArrayHelper::getColumn(TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(),'lang.alias'); } parent::init(); @@ -69,8 +58,6 @@ class Seo extends Widget } - - switch ($this->row) { case self::SEO_TEXT: @@ -81,22 +68,25 @@ class Seo extends Widget if(empty($filter) && empty($sort) && empty($paginate) ){ - return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter, $this->widgetData, $this->widgetData, $priority)); + return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter,$priority)); } else { + $widgetData = static::findSeoByUrl($this->url); $result = ''; - if ($this->widgetData instanceof \artweb\artbox\seo\models\Seo) { + if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { - $result = $this->widgetData->{self::SEO_TEXT}; + $result = $widgetData->{self::SEO_TEXT}; } else { - if ($this->widgetData instanceof SeoDynamic) { + $widgetData = $this->findSeoByDynamic(); - $result = $this->widgetData->lang->{self::SEO_TEXT}; + if ($widgetData instanceof SeoDynamic) { + + $result = $widgetData->lang->{self::SEO_TEXT}; } @@ -111,7 +101,7 @@ class Seo extends Widget $filter = \Yii::$app->request->get('filters', []); - $default = $this->selectSeoData(self::H1, $filter, $this->widgetData, $this->widgetData, $priority); + $default = $this->selectSeoData(self::H1, $filter,$priority); if ($default != $this->{self::H1}) { @@ -132,10 +122,11 @@ class Seo extends Widget $filter = \Yii::$app->request->get('filters', []); - $title = $this->selectSeoData(self::TITLE, $filter, $this->widgetData, $this->widgetData, $priority); - + $title = $this->selectSeoData(self::TITLE, $filter,$priority); + print_r($this->{Seo::TITLE}); + die('here'); - if(!empty($filter) && $priority==3 || !empty($filter) && empty($this->{Seo::TITLE})) { + if(!empty($filter) && $title == $this->{Seo::TITLE} || !empty($filter) && empty($this->{Seo::TITLE})) { $array = $this->arrayBuilder($filter); @@ -153,12 +144,13 @@ class Seo extends Widget } else { return $this->prepareString($this->project_name); } + die('here2'); break; case self::DESCRIPTION: $filter = \Yii::$app->request->get('filters', []); - $description = $this->selectSeoData(self::DESCRIPTION, $filter, $this->widgetData, $this->widgetData, $priority); + $description = $this->selectSeoData(self::DESCRIPTION, $filter,$priority); if (!empty($description)) { @@ -187,7 +179,7 @@ class Seo extends Widget $sort = \Yii::$app->request->get('sort', []); $paginate = \Yii::$app->request->get('page', []); - $meta = $this->selectSeoData(self::META, $filter, $this->widgetData, $this->widgetData, $priority); + $meta = $this->selectSeoData(self::META, $filter,$priority); if(!empty($filter) && !$this->checkFilter($filter) && count($filter, COUNT_RECURSIVE) == 2){ $key = array_keys ( $filter); @@ -331,15 +323,15 @@ class Seo extends Widget * @param $param * @param $filter * @param $priority - * @param $widgetData - * @param $widgetDynamicData * @return mixed */ - protected function selectSeoData($param, $filter, $widgetData, $widgetDynamicData, &$priority) + protected function selectSeoData($param, $filter, &$priority) { $result = ''; + $widgetData = static::findSeoByUrl($this->url); + $widgetDynamicData = $this->findSeoByDynamic(); if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { $priority = 1; @@ -434,7 +426,7 @@ class Seo extends Widget } - $optionsList = ArrayHelper::map(self::$optionsListObject, 'lang.alias', 'name'); + $optionsList = ArrayHelper::map(TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(), 'lang.alias', 'name'); foreach ($optionsList as $optionList => $name) { -- libgit2 0.21.4