Commit b5777d7813b967a54f9287e6b3d8fdd9e0300050
1 parent
3d4c48f5
add variantSku
Showing
1 changed file
with
14 additions
and
9 deletions
Show diff stats
widgets/Seo.php
... | ... | @@ -68,7 +68,7 @@ class Seo extends Widget |
68 | 68 | |
69 | 69 | if(empty($filter) && empty($sort) && empty($paginate) ){ |
70 | 70 | |
71 | - return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter)); | |
71 | + return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter,$priority)); | |
72 | 72 | |
73 | 73 | } else { |
74 | 74 | |
... | ... | @@ -101,7 +101,7 @@ class Seo extends Widget |
101 | 101 | |
102 | 102 | $filter = \Yii::$app->request->get('filters', []); |
103 | 103 | |
104 | - $default = $this->selectSeoData(self::H1, $filter); | |
104 | + $default = $this->selectSeoData(self::H1, $filter,$priority); | |
105 | 105 | |
106 | 106 | if ($default != $this->{self::H1}) { |
107 | 107 | |
... | ... | @@ -122,10 +122,10 @@ class Seo extends Widget |
122 | 122 | $filter = \Yii::$app->request->get('filters', []); |
123 | 123 | |
124 | 124 | |
125 | - $title = $this->selectSeoData(self::TITLE, $filter); | |
125 | + $title = $this->selectSeoData(self::TITLE, $filter,$priority); | |
126 | 126 | |
127 | 127 | |
128 | - if(!empty($filter) && $title == $this->{Seo::TITLE} || !empty($filter) && empty($this->{Seo::TITLE})) { | |
128 | + if(!empty($filter) && $priority==3 || !empty($filter) && empty($this->{Seo::TITLE})) { | |
129 | 129 | |
130 | 130 | $array = $this->arrayBuilder($filter); |
131 | 131 | |
... | ... | @@ -143,13 +143,12 @@ class Seo extends Widget |
143 | 143 | } else { |
144 | 144 | return $this->prepareString($this->project_name); |
145 | 145 | } |
146 | - | |
147 | 146 | break; |
148 | 147 | case self::DESCRIPTION: |
149 | 148 | |
150 | 149 | $filter = \Yii::$app->request->get('filters', []); |
151 | 150 | |
152 | - $description = $this->selectSeoData(self::DESCRIPTION, $filter); | |
151 | + $description = $this->selectSeoData(self::DESCRIPTION, $filter,$priority); | |
153 | 152 | |
154 | 153 | if (!empty($description)) { |
155 | 154 | |
... | ... | @@ -178,7 +177,7 @@ class Seo extends Widget |
178 | 177 | $sort = \Yii::$app->request->get('sort', []); |
179 | 178 | $paginate = \Yii::$app->request->get('page', []); |
180 | 179 | |
181 | - $meta = $this->selectSeoData(self::META, $filter); | |
180 | + $meta = $this->selectSeoData(self::META, $filter,$priority); | |
182 | 181 | |
183 | 182 | if(!empty($filter) && !$this->checkFilter($filter) && count($filter, COUNT_RECURSIVE) == 2){ |
184 | 183 | $key = array_keys ( $filter); |
... | ... | @@ -282,6 +281,9 @@ class Seo extends Widget |
282 | 281 | protected function findSeoByDynamic() |
283 | 282 | { |
284 | 283 | |
284 | +// print_r(\Yii::$app->controller->id); | |
285 | +// print_r(\Yii::$app->controller->action->id); | |
286 | +// die(); | |
285 | 287 | if(!empty($this->key)){ |
286 | 288 | |
287 | 289 | $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id, 'key' => $this->key]); |
... | ... | @@ -318,11 +320,11 @@ class Seo extends Widget |
318 | 320 | /** |
319 | 321 | * @param $param |
320 | 322 | * @param $filter |
323 | + * @param $priority | |
321 | 324 | * @return mixed |
322 | 325 | */ |
323 | - protected function selectSeoData($param, $filter) | |
326 | + protected function selectSeoData($param, $filter, &$priority) | |
324 | 327 | { |
325 | - | |
326 | 328 | $result = ''; |
327 | 329 | |
328 | 330 | $widgetData = static::findSeoByUrl($this->url); |
... | ... | @@ -330,12 +332,15 @@ class Seo extends Widget |
330 | 332 | $widgetDynamicData = $this->findSeoByDynamic(); |
331 | 333 | |
332 | 334 | if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { |
335 | + $priority = 1; | |
333 | 336 | $result = $widgetData->$param; |
334 | 337 | |
335 | 338 | }else if(!empty($this->$param) && empty($filter)) { |
339 | + $priority = 2; | |
336 | 340 | $result = $this->$param; |
337 | 341 | |
338 | 342 | } else if ($widgetDynamicData instanceof SeoDynamic) { |
343 | + $priority = 3; | |
339 | 344 | $result = $widgetDynamicData->lang->$param; |
340 | 345 | |
341 | 346 | } | ... | ... |