Jump to content
Sign in to follow this  

MultiMerch транслитерация имен картинок

Recommended Posts

Заставить русскоязычную аудиторию переименовывать имена файлов на латиницу практически невозможно.
По этому сделан следующий костыль. (ну не программист я а обращение к разработчику результатов не дало)
В файле system\library\msfile.php находим

public function uploadImage($file) {
        $filename =   time() . '_' . md5(rand()) . '.' . $file["name"];

и меняем на

public function uploadImage($file) {

$translit = array("а"=>"a","б"=>"b","в"=>"v","г"=>"g","д"=>"d","е"=>"e", "ё"=>"yo","ж"=>"j","з"=>"z","и"=>"i","й"=>"i","к"=>"k","л"=>"l", "м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r","с"=>"s","т"=>"t", "у"=>"y","ф"=>"f","х"=>"h","ц"=>"c","ч"=>"ch", "ш"=>"sh","щ"=>"sh","ы"=>"i","э"=>"e","ю"=>"u","я"=>"ya",
  "А"=>"A","Б"=>"B","В"=>"V","Г"=>"G","Д"=>"D","Е"=>"E", "Ё"=>"Yo","Ж"=>"J","З"=>"Z","И"=>"I","Й"=>"I","К"=>"K", "Л"=>"L","М"=>"M","Н"=>"N","О"=>"O","П"=>"P", "Р"=>"R","С"=>"S","Т"=>"T","У"=>"Y","Ф"=>"F", "Х"=>"H","Ц"=>"C","Ч"=>"Ch","Ш"=>"Sh","Щ"=>"Sh", "Ы"=>"I","Э"=>"E","Ю"=>"U","Я"=>"Ya",
  "ь"=>"","Ь"=>"","ъ"=>"","Ъ"=>""," "=>"_");

$latfilename=strtr($file['name'], $translit);
$latfilename = mb_strtolower( $latfilename, 'UTF-8');
$filename =   time() . '_' . md5(rand()) . '.' . $latfilename;

Сам ищу решение  по ресайзу загружаемой картинки (у самого не получается пока) -  пользователь грузит 2048х2048 px а сохраняется 1024х1024 px.


Edited by Nashlab

Share this post

Link to post
Share on other sites

Глянь model/tool/image.php

Share this post

Link to post
Share on other sites

Классное решение! А для транслитерации чпу случайно не знаете решение? А то получается site.com/товар-на-кириллице, и соответственно в sitemap.xml такая же беда. Ставлю эксперименты с translit.js и кучу модулей перепробовал - на multimerch не могу заставить систему автоматически генерить чпу с транлитом на латиницу (((

Share this post

Link to post
Share on other sites

Я так понял копать надо здесь catalog/controller/seller/account-product.php, каким-то образом вставить транслитерацию на латиницу ... но я также не программист и не могу разобраться как? (

		// SEO urls generation for products
		if ($this->config->get('msconf_enable_seo_urls_product')) {
			$latin_check = '/[^\x{0030}-\x{007f}]/u';
			$product_name = $data['languages'][$default]['product_name'];
			$non_latin_chars = preg_match($latin_check, $product_name);
			if ($this->config->get('msconf_enable_non_alphanumeric_seo') && $non_latin_chars) {
				$data['keyword'] = implode("-", str_replace("-", "", explode(" ", preg_replace("/[^\p{L}\p{N} ]/u", '', strtolower($product_name)))));
			else {
				$data['keyword'] = implode("-", str_replace("-", "", explode(" ", preg_replace("/[^A-Za-z0-9 ]/", '', strtolower($product_name)))));
Edited by mojo

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.


Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.