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