Commit 52ac578820415ebd1388a37577ee1ecdd82cf908
1 parent
b5777d78
add variantSku
Showing
1 changed file
with
27 additions
and
17 deletions
Show diff stats
widgets/Seo.php
| ... | ... | @@ -23,6 +23,10 @@ class Seo extends Widget |
| 23 | 23 | public $key; |
| 24 | 24 | public $name; |
| 25 | 25 | public $project_name; |
| 26 | + public $widgetData; | |
| 27 | + | |
| 28 | + public $widgetDynamicData; | |
| 29 | + public static $optionsListObject; | |
| 26 | 30 | public static $optionsList; |
| 27 | 31 | protected static $check_url; |
| 28 | 32 | protected static $check_url_bool; |
| ... | ... | @@ -37,9 +41,16 @@ class Seo extends Widget |
| 37 | 41 | public function init() |
| 38 | 42 | { |
| 39 | 43 | $this->url = \Yii::$app->request->url; |
| 44 | + | |
| 40 | 45 | $this->project_name = \Yii::$app->name; |
| 46 | + | |
| 47 | + $this->widgetData = static::findSeoByUrl($this->url); | |
| 48 | + | |
| 49 | + $this->widgetDynamicData = $this->findSeoByDynamic(); | |
| 50 | + | |
| 41 | 51 | if(empty(self::$optionsList)){ |
| 42 | - self::$optionsList = ArrayHelper::getColumn(TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(),'lang.alias'); | |
| 52 | + self::$optionsListObject = TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(); | |
| 53 | + self::$optionsList = ArrayHelper::getColumn(self::$optionsListObject,'lang.alias'); | |
| 43 | 54 | } |
| 44 | 55 | |
| 45 | 56 | parent::init(); |
| ... | ... | @@ -58,6 +69,8 @@ class Seo extends Widget |
| 58 | 69 | } |
| 59 | 70 | |
| 60 | 71 | |
| 72 | + | |
| 73 | + | |
| 61 | 74 | switch ($this->row) { |
| 62 | 75 | case self::SEO_TEXT: |
| 63 | 76 | |
| ... | ... | @@ -68,25 +81,22 @@ class Seo extends Widget |
| 68 | 81 | |
| 69 | 82 | if(empty($filter) && empty($sort) && empty($paginate) ){ |
| 70 | 83 | |
| 71 | - return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter,$priority)); | |
| 84 | + return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter, $this->widgetData, $this->widgetData, $priority)); | |
| 72 | 85 | |
| 73 | 86 | } else { |
| 74 | 87 | |
| 75 | - $widgetData = static::findSeoByUrl($this->url); | |
| 76 | 88 | |
| 77 | 89 | $result = ''; |
| 78 | 90 | |
| 79 | - if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { | |
| 91 | + if ($this->widgetData instanceof \artweb\artbox\seo\models\Seo) { | |
| 80 | 92 | |
| 81 | - $result = $widgetData->{self::SEO_TEXT}; | |
| 93 | + $result = $this->widgetData->{self::SEO_TEXT}; | |
| 82 | 94 | |
| 83 | 95 | } else { |
| 84 | 96 | |
| 85 | - $widgetData = $this->findSeoByDynamic(); | |
| 86 | - | |
| 87 | - if ($widgetData instanceof SeoDynamic) { | |
| 97 | + if ($this->widgetData instanceof SeoDynamic) { | |
| 88 | 98 | |
| 89 | - $result = $widgetData->lang->{self::SEO_TEXT}; | |
| 99 | + $result = $this->widgetData->lang->{self::SEO_TEXT}; | |
| 90 | 100 | |
| 91 | 101 | } |
| 92 | 102 | |
| ... | ... | @@ -101,7 +111,7 @@ class Seo extends Widget |
| 101 | 111 | |
| 102 | 112 | $filter = \Yii::$app->request->get('filters', []); |
| 103 | 113 | |
| 104 | - $default = $this->selectSeoData(self::H1, $filter,$priority); | |
| 114 | + $default = $this->selectSeoData(self::H1, $filter, $this->widgetData, $this->widgetData, $priority); | |
| 105 | 115 | |
| 106 | 116 | if ($default != $this->{self::H1}) { |
| 107 | 117 | |
| ... | ... | @@ -122,7 +132,7 @@ class Seo extends Widget |
| 122 | 132 | $filter = \Yii::$app->request->get('filters', []); |
| 123 | 133 | |
| 124 | 134 | |
| 125 | - $title = $this->selectSeoData(self::TITLE, $filter,$priority); | |
| 135 | + $title = $this->selectSeoData(self::TITLE, $filter, $this->widgetData, $this->widgetData, $priority); | |
| 126 | 136 | |
| 127 | 137 | |
| 128 | 138 | if(!empty($filter) && $priority==3 || !empty($filter) && empty($this->{Seo::TITLE})) { |
| ... | ... | @@ -148,7 +158,7 @@ class Seo extends Widget |
| 148 | 158 | |
| 149 | 159 | $filter = \Yii::$app->request->get('filters', []); |
| 150 | 160 | |
| 151 | - $description = $this->selectSeoData(self::DESCRIPTION, $filter,$priority); | |
| 161 | + $description = $this->selectSeoData(self::DESCRIPTION, $filter, $this->widgetData, $this->widgetData, $priority); | |
| 152 | 162 | |
| 153 | 163 | if (!empty($description)) { |
| 154 | 164 | |
| ... | ... | @@ -177,7 +187,7 @@ class Seo extends Widget |
| 177 | 187 | $sort = \Yii::$app->request->get('sort', []); |
| 178 | 188 | $paginate = \Yii::$app->request->get('page', []); |
| 179 | 189 | |
| 180 | - $meta = $this->selectSeoData(self::META, $filter,$priority); | |
| 190 | + $meta = $this->selectSeoData(self::META, $filter, $this->widgetData, $this->widgetData, $priority); | |
| 181 | 191 | |
| 182 | 192 | if(!empty($filter) && !$this->checkFilter($filter) && count($filter, COUNT_RECURSIVE) == 2){ |
| 183 | 193 | $key = array_keys ( $filter); |
| ... | ... | @@ -321,15 +331,15 @@ class Seo extends Widget |
| 321 | 331 | * @param $param |
| 322 | 332 | * @param $filter |
| 323 | 333 | * @param $priority |
| 334 | + * @param $widgetData | |
| 335 | + * @param $widgetDynamicData | |
| 324 | 336 | * @return mixed |
| 325 | 337 | */ |
| 326 | - protected function selectSeoData($param, $filter, &$priority) | |
| 338 | + protected function selectSeoData($param, $filter, $widgetData, $widgetDynamicData, &$priority) | |
| 327 | 339 | { |
| 328 | 340 | $result = ''; |
| 329 | 341 | |
| 330 | - $widgetData = static::findSeoByUrl($this->url); | |
| 331 | 342 | |
| 332 | - $widgetDynamicData = $this->findSeoByDynamic(); | |
| 333 | 343 | |
| 334 | 344 | if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { |
| 335 | 345 | $priority = 1; |
| ... | ... | @@ -424,7 +434,7 @@ class Seo extends Widget |
| 424 | 434 | } |
| 425 | 435 | |
| 426 | 436 | |
| 427 | - $optionsList = ArrayHelper::map(TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(), 'lang.alias', 'name'); | |
| 437 | + $optionsList = ArrayHelper::map(self::$optionsListObject, 'lang.alias', 'name'); | |
| 428 | 438 | |
| 429 | 439 | |
| 430 | 440 | foreach ($optionsList as $optionList => $name) { | ... | ... |