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,6 +23,10 @@ class Seo extends Widget | ||
23 | public $key; | 23 | public $key; |
24 | public $name; | 24 | public $name; |
25 | public $project_name; | 25 | public $project_name; |
26 | + public $widgetData; | ||
27 | + | ||
28 | + public $widgetDynamicData; | ||
29 | + public static $optionsListObject; | ||
26 | public static $optionsList; | 30 | public static $optionsList; |
27 | protected static $check_url; | 31 | protected static $check_url; |
28 | protected static $check_url_bool; | 32 | protected static $check_url_bool; |
@@ -37,9 +41,16 @@ class Seo extends Widget | @@ -37,9 +41,16 @@ class Seo extends Widget | ||
37 | public function init() | 41 | public function init() |
38 | { | 42 | { |
39 | $this->url = \Yii::$app->request->url; | 43 | $this->url = \Yii::$app->request->url; |
44 | + | ||
40 | $this->project_name = \Yii::$app->name; | 45 | $this->project_name = \Yii::$app->name; |
46 | + | ||
47 | + $this->widgetData = static::findSeoByUrl($this->url); | ||
48 | + | ||
49 | + $this->widgetDynamicData = $this->findSeoByDynamic(); | ||
50 | + | ||
41 | if(empty(self::$optionsList)){ | 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 | parent::init(); | 56 | parent::init(); |
@@ -58,6 +69,8 @@ class Seo extends Widget | @@ -58,6 +69,8 @@ class Seo extends Widget | ||
58 | } | 69 | } |
59 | 70 | ||
60 | 71 | ||
72 | + | ||
73 | + | ||
61 | switch ($this->row) { | 74 | switch ($this->row) { |
62 | case self::SEO_TEXT: | 75 | case self::SEO_TEXT: |
63 | 76 | ||
@@ -68,25 +81,22 @@ class Seo extends Widget | @@ -68,25 +81,22 @@ class Seo extends Widget | ||
68 | 81 | ||
69 | if(empty($filter) && empty($sort) && empty($paginate) ){ | 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 | } else { | 86 | } else { |
74 | 87 | ||
75 | - $widgetData = static::findSeoByUrl($this->url); | ||
76 | 88 | ||
77 | $result = ''; | 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 | } else { | 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,7 +111,7 @@ class Seo extends Widget | ||
101 | 111 | ||
102 | $filter = \Yii::$app->request->get('filters', []); | 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 | if ($default != $this->{self::H1}) { | 116 | if ($default != $this->{self::H1}) { |
107 | 117 | ||
@@ -122,7 +132,7 @@ class Seo extends Widget | @@ -122,7 +132,7 @@ class Seo extends Widget | ||
122 | $filter = \Yii::$app->request->get('filters', []); | 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 | if(!empty($filter) && $priority==3 || !empty($filter) && empty($this->{Seo::TITLE})) { | 138 | if(!empty($filter) && $priority==3 || !empty($filter) && empty($this->{Seo::TITLE})) { |
@@ -148,7 +158,7 @@ class Seo extends Widget | @@ -148,7 +158,7 @@ class Seo extends Widget | ||
148 | 158 | ||
149 | $filter = \Yii::$app->request->get('filters', []); | 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 | if (!empty($description)) { | 163 | if (!empty($description)) { |
154 | 164 | ||
@@ -177,7 +187,7 @@ class Seo extends Widget | @@ -177,7 +187,7 @@ class Seo extends Widget | ||
177 | $sort = \Yii::$app->request->get('sort', []); | 187 | $sort = \Yii::$app->request->get('sort', []); |
178 | $paginate = \Yii::$app->request->get('page', []); | 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 | if(!empty($filter) && !$this->checkFilter($filter) && count($filter, COUNT_RECURSIVE) == 2){ | 192 | if(!empty($filter) && !$this->checkFilter($filter) && count($filter, COUNT_RECURSIVE) == 2){ |
183 | $key = array_keys ( $filter); | 193 | $key = array_keys ( $filter); |
@@ -321,15 +331,15 @@ class Seo extends Widget | @@ -321,15 +331,15 @@ class Seo extends Widget | ||
321 | * @param $param | 331 | * @param $param |
322 | * @param $filter | 332 | * @param $filter |
323 | * @param $priority | 333 | * @param $priority |
334 | + * @param $widgetData | ||
335 | + * @param $widgetDynamicData | ||
324 | * @return mixed | 336 | * @return mixed |
325 | */ | 337 | */ |
326 | - protected function selectSeoData($param, $filter, &$priority) | 338 | + protected function selectSeoData($param, $filter, $widgetData, $widgetDynamicData, &$priority) |
327 | { | 339 | { |
328 | $result = ''; | 340 | $result = ''; |
329 | 341 | ||
330 | - $widgetData = static::findSeoByUrl($this->url); | ||
331 | 342 | ||
332 | - $widgetDynamicData = $this->findSeoByDynamic(); | ||
333 | 343 | ||
334 | if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { | 344 | if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { |
335 | $priority = 1; | 345 | $priority = 1; |
@@ -424,7 +434,7 @@ class Seo extends Widget | @@ -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 | foreach ($optionsList as $optionList => $name) { | 440 | foreach ($optionsList as $optionList => $name) { |