diff --git a/common/behaviors/Slug.php b/common/behaviors/Slug.php index 4b316cf..1fad8b9 100755 --- a/common/behaviors/Slug.php +++ b/common/behaviors/Slug.php @@ -22,7 +22,6 @@ class Slug extends Behavior public function getSlug( $event ) { - if(!empty($this->owner->{$this->in_attribute})){ if ( empty( $this->owner->{$this->out_attribute} ) ) { $this->owner->{$this->out_attribute} = $this->generateSlug( $this->owner->{$this->in_attribute} ); @@ -47,7 +46,7 @@ class Slug extends Behavior private function slugify( $slug ) { if ( $this->translit ) { - return yii\helpers\Inflector::slug( TransliteratorHelper::process( $slug ), '-', true ); + return yii\helpers\Inflector::slug( $this->translit( $slug ), '-', true ); } else { return $this->slug( $slug, '-', true ); } @@ -77,4 +76,69 @@ class Slug extends Behavior ->one(); } + + static function translit ($string, $setting = 'all') + { + $letter = array ( + + 'а' => 'a', 'б' => 'b', 'в' => 'v', + 'г' => 'g', 'д' => 'd', 'е' => 'e', + 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', + 'и' => 'i', 'й' => 'y', 'к' => 'k', + 'л' => 'l', 'м' => 'm', 'н' => 'n', + 'о' => 'o', 'п' => 'p', 'р' => 'r', + 'с' => 's', 'т' => 't', 'у' => 'u', + 'ф' => 'f', 'х' => 'h', 'ц' => 'c', + 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', + 'ь' => "", 'ы' => 'y', 'ъ' => "", + 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', + 'ї' => 'yi', 'є' => 'ye', 'і' => 'ee', + + 'А' => 'A', 'Б' => 'B', 'В' => 'V', + 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', + 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', + 'И' => 'I', 'Й' => 'Y', 'К' => 'K', + 'Л' => 'L', 'М' => 'M', 'Н' => 'N', + 'О' => 'O', 'П' => 'P', 'Р' => 'R', + 'С' => 'S', 'Т' => 'T', 'У' => 'U', + 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', + 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch', + 'Ь' => "", 'Ы' => 'Y', 'Ъ' => "", + 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', + 'Ї' => 'Yi', 'Є' => 'Ye', 'І' => 'Ee' + ); + + $symbol = array ( + ' ' => '-', "'" => '', '"' => '', + '!' => '', "@" => '', '#' => '', + '$' => '', "%" => '', '^' => '', + ';' => '', "*" => '', '(' => '', + ')' => '', "+" => '', '~' => '', + '.' => '', ',' => '-', '?' => '', + '…' => '', '№' => 'N', '°' => '', + '`' => '', '|' => '', '&' => '-and-', + '<' => '', '>' => '' + ); + + if ($setting == 'all') + { + $converter = $letter + $symbol; + } + else if ($setting == 'letter') + { + $converter = $letter; + } + else if ($setting == 'symbol') + { + $converter = $symbol; + } + + $url = strtr ($string, $converter); + + $url = str_replace ("---", '-', $url); + $url = str_replace ("--", '-', $url); + + return $url; + } + } \ No newline at end of file diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php index 909fde5..a94cecf 100755 --- a/common/modules/product/CatalogUrlManager.php +++ b/common/modules/product/CatalogUrlManager.php @@ -171,7 +171,7 @@ class CatalogUrlManager implements UrlRuleInterface { $filter_options = explode(';', $filter_str); foreach ($filter_options as $filter_option) { $filter_exp = explode('=', $filter_option); - if(is_array($filter_exp)){ + if(!empty($filter_exp[1])){ list($filter_key, $filter_option) = explode('=', $filter_option); if($filter_key == 'prices') { // price-interval section $prices = explode(':', $filter_option); diff --git a/common/modules/product/models/Export.php b/common/modules/product/models/Export.php index 3865054..cc0736a 100644 --- a/common/modules/product/models/Export.php +++ b/common/modules/product/models/Export.php @@ -2,6 +2,7 @@ namespace common\modules\product\models; + use common\modules\rubrication\models\TaxGroup; use yii\base\Model; class Export extends Model @@ -26,13 +27,12 @@ $products = Product::find() - ->joinWith([ + ->with([ 'variantsWithFilters', 'brand', 'categories', - ]) - ->with('filters') - ->limit(1000) + 'filters']) + ->limit(100) ->offset($from) ->all(); $filesize = Product::find() @@ -58,7 +58,7 @@ $list = [ $categories, - $product->brand->name, + !empty($product->brand) ? $product->brand ->name :'', $product->name, '', ( ( !empty( $product->description ) ) ? $product->description : '' ), @@ -79,7 +79,7 @@ fclose($handle); - $from += 1000; + $from += 100; $end = false; if($from > $filesize) { $end = true; @@ -104,16 +104,22 @@ public function convertFilterToString($filters) { - $fittersArray = []; - foreach($filters as $filter) { - $fittersArray[ $filter->taxGroup->alias ][] = $filter->value; + if(!empty($filters)){ + $fittersArray = []; + foreach($filters as $filter) { + if($filter->taxGroup instanceof TaxGroup){ + $fittersArray[ $filter->taxGroup->alias ][] = $filter->value; + } + + } + $filterString = []; + + foreach($fittersArray as $filterName => $filterRows) { + $row = implode(',', $filterRows); + $filterString[] = "[{$filterName}:{$row}]"; + } + return implode('*', $filterString); } - $filterString = []; - - foreach($fittersArray as $filterName => $filterRows) { - $row = implode(',', $filterRows); - $filterString[] = "[{$filterName}:{$row}]"; - } - return implode('*', $filterString); + } } \ No newline at end of file diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 87bd9f9..94905c7 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -93,10 +93,8 @@ class SiteController extends Controller } public function actionError(){ - return $this->render('error', [ 'code'=>'404', -// 'message'=>Yii::$app->errorHandler->exception->getMessage(), ]); } } -- libgit2 0.21.4