Commit 63e867f2b4f99fedfdd89c2f4b261b33cd469f22
1 parent
ec2fe6c9
big commti
Showing
4 changed files
with
89 additions
and
21 deletions
Show diff stats
common/behaviors/Slug.php
... | ... | @@ -22,7 +22,6 @@ class Slug extends Behavior |
22 | 22 | |
23 | 23 | public function getSlug( $event ) |
24 | 24 | { |
25 | - | |
26 | 25 | if(!empty($this->owner->{$this->in_attribute})){ |
27 | 26 | if ( empty( $this->owner->{$this->out_attribute} ) ) { |
28 | 27 | $this->owner->{$this->out_attribute} = $this->generateSlug( $this->owner->{$this->in_attribute} ); |
... | ... | @@ -47,7 +46,7 @@ class Slug extends Behavior |
47 | 46 | private function slugify( $slug ) |
48 | 47 | { |
49 | 48 | if ( $this->translit ) { |
50 | - return yii\helpers\Inflector::slug( TransliteratorHelper::process( $slug ), '-', true ); | |
49 | + return yii\helpers\Inflector::slug( $this->translit( $slug ), '-', true ); | |
51 | 50 | } else { |
52 | 51 | return $this->slug( $slug, '-', true ); |
53 | 52 | } |
... | ... | @@ -77,4 +76,69 @@ class Slug extends Behavior |
77 | 76 | ->one(); |
78 | 77 | } |
79 | 78 | |
79 | + | |
80 | + static function translit ($string, $setting = 'all') | |
81 | + { | |
82 | + $letter = array ( | |
83 | + | |
84 | + 'а' => 'a', 'б' => 'b', 'в' => 'v', | |
85 | + 'г' => 'g', 'д' => 'd', 'е' => 'e', | |
86 | + 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', | |
87 | + 'и' => 'i', 'й' => 'y', 'к' => 'k', | |
88 | + 'л' => 'l', 'м' => 'm', 'н' => 'n', | |
89 | + 'о' => 'o', 'п' => 'p', 'р' => 'r', | |
90 | + 'с' => 's', 'т' => 't', 'у' => 'u', | |
91 | + 'ф' => 'f', 'х' => 'h', 'ц' => 'c', | |
92 | + 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', | |
93 | + 'ь' => "", 'ы' => 'y', 'ъ' => "", | |
94 | + 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', | |
95 | + 'ї' => 'yi', 'є' => 'ye', 'і' => 'ee', | |
96 | + | |
97 | + 'А' => 'A', 'Б' => 'B', 'В' => 'V', | |
98 | + 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', | |
99 | + 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', | |
100 | + 'И' => 'I', 'Й' => 'Y', 'К' => 'K', | |
101 | + 'Л' => 'L', 'М' => 'M', 'Н' => 'N', | |
102 | + 'О' => 'O', 'П' => 'P', 'Р' => 'R', | |
103 | + 'С' => 'S', 'Т' => 'T', 'У' => 'U', | |
104 | + 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', | |
105 | + 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch', | |
106 | + 'Ь' => "", 'Ы' => 'Y', 'Ъ' => "", | |
107 | + 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', | |
108 | + 'Ї' => 'Yi', 'Є' => 'Ye', 'І' => 'Ee' | |
109 | + ); | |
110 | + | |
111 | + $symbol = array ( | |
112 | + ' ' => '-', "'" => '', '"' => '', | |
113 | + '!' => '', "@" => '', '#' => '', | |
114 | + '$' => '', "%" => '', '^' => '', | |
115 | + ';' => '', "*" => '', '(' => '', | |
116 | + ')' => '', "+" => '', '~' => '', | |
117 | + '.' => '', ',' => '-', '?' => '', | |
118 | + '…' => '', '№' => 'N', '°' => '', | |
119 | + '`' => '', '|' => '', '&' => '-and-', | |
120 | + '<' => '', '>' => '' | |
121 | + ); | |
122 | + | |
123 | + if ($setting == 'all') | |
124 | + { | |
125 | + $converter = $letter + $symbol; | |
126 | + } | |
127 | + else if ($setting == 'letter') | |
128 | + { | |
129 | + $converter = $letter; | |
130 | + } | |
131 | + else if ($setting == 'symbol') | |
132 | + { | |
133 | + $converter = $symbol; | |
134 | + } | |
135 | + | |
136 | + $url = strtr ($string, $converter); | |
137 | + | |
138 | + $url = str_replace ("---", '-', $url); | |
139 | + $url = str_replace ("--", '-', $url); | |
140 | + | |
141 | + return $url; | |
142 | + } | |
143 | + | |
80 | 144 | } |
81 | 145 | \ No newline at end of file | ... | ... |
common/modules/product/CatalogUrlManager.php
... | ... | @@ -171,7 +171,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
171 | 171 | $filter_options = explode(';', $filter_str); |
172 | 172 | foreach ($filter_options as $filter_option) { |
173 | 173 | $filter_exp = explode('=', $filter_option); |
174 | - if(is_array($filter_exp)){ | |
174 | + if(!empty($filter_exp[1])){ | |
175 | 175 | list($filter_key, $filter_option) = explode('=', $filter_option); |
176 | 176 | if($filter_key == 'prices') { // price-interval section |
177 | 177 | $prices = explode(':', $filter_option); | ... | ... |
common/modules/product/models/Export.php
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | namespace common\modules\product\models; |
4 | 4 | |
5 | + use common\modules\rubrication\models\TaxGroup; | |
5 | 6 | use yii\base\Model; |
6 | 7 | |
7 | 8 | class Export extends Model |
... | ... | @@ -26,13 +27,12 @@ |
26 | 27 | |
27 | 28 | |
28 | 29 | $products = Product::find() |
29 | - ->joinWith([ | |
30 | + ->with([ | |
30 | 31 | 'variantsWithFilters', |
31 | 32 | 'brand', |
32 | 33 | 'categories', |
33 | - ]) | |
34 | - ->with('filters') | |
35 | - ->limit(1000) | |
34 | + 'filters']) | |
35 | + ->limit(100) | |
36 | 36 | ->offset($from) |
37 | 37 | ->all(); |
38 | 38 | $filesize = Product::find() |
... | ... | @@ -58,7 +58,7 @@ |
58 | 58 | |
59 | 59 | $list = [ |
60 | 60 | $categories, |
61 | - $product->brand->name, | |
61 | + !empty($product->brand) ? $product->brand ->name :'', | |
62 | 62 | $product->name, |
63 | 63 | '', |
64 | 64 | ( ( !empty( $product->description ) ) ? $product->description : '' ), |
... | ... | @@ -79,7 +79,7 @@ |
79 | 79 | |
80 | 80 | fclose($handle); |
81 | 81 | |
82 | - $from += 1000; | |
82 | + $from += 100; | |
83 | 83 | $end = false; |
84 | 84 | if($from > $filesize) { |
85 | 85 | $end = true; |
... | ... | @@ -104,16 +104,22 @@ |
104 | 104 | |
105 | 105 | public function convertFilterToString($filters) |
106 | 106 | { |
107 | - $fittersArray = []; | |
108 | - foreach($filters as $filter) { | |
109 | - $fittersArray[ $filter->taxGroup->alias ][] = $filter->value; | |
107 | + if(!empty($filters)){ | |
108 | + $fittersArray = []; | |
109 | + foreach($filters as $filter) { | |
110 | + if($filter->taxGroup instanceof TaxGroup){ | |
111 | + $fittersArray[ $filter->taxGroup->alias ][] = $filter->value; | |
112 | + } | |
113 | + | |
114 | + } | |
115 | + $filterString = []; | |
116 | + | |
117 | + foreach($fittersArray as $filterName => $filterRows) { | |
118 | + $row = implode(',', $filterRows); | |
119 | + $filterString[] = "[{$filterName}:{$row}]"; | |
120 | + } | |
121 | + return implode('*', $filterString); | |
110 | 122 | } |
111 | - $filterString = []; | |
112 | - | |
113 | - foreach($fittersArray as $filterName => $filterRows) { | |
114 | - $row = implode(',', $filterRows); | |
115 | - $filterString[] = "[{$filterName}:{$row}]"; | |
116 | - } | |
117 | - return implode('*', $filterString); | |
123 | + | |
118 | 124 | } |
119 | 125 | } |
120 | 126 | \ No newline at end of file | ... | ... |
frontend/controllers/SiteController.php