Jump to content

PrestaShop 1.5.1 - friendly URL komplikace s českými znaky


HitmanCZ

Recommended Posts

polozka friendly URL se stale a stale doplnuje s hacky a carky z nazvu produktu. kdyz to opravim a ulozim, je to spravne. ale kdyz produkt otevru k editaci, napr. popisu produktu a ulozim, pole Friendly URL se opet prepise s hacky/carky z popisu produktu.

 

nechci se pak prat se seo a marketingem kvuli ceskym znakum v url.

 

upravil jsem admin.js ale porad mi to tam hazi ceske znaky, str2url je neprepise podle zadanych pravidel

Edited by HitmanCZ (see edit history)
Link to comment
Share on other sites

jedno reseni je od jacka

 

<?php
function friendly_url($nadpis) {
   $url = $nadpis;
   $url = strip_tags(html_entity_decode($url));
   $url = iconv("UTF-8","windows-1250"."//TRANSLIT",$url);
   $noalpha = "\xc1\xc9\xcd\xd3\xda\xdd\xe1\xe9\xed\xf3\xfa\xfd\xc2\xca\xce\xd4\xdb\xe2\xea\xee\xf4\xfb\xc0\xc8\xcc\xd2\xd9\xe0\xe8\xec\xf2\xf9\xc4\xcb\xcf\xd6\xdc\xe4\xeb\xef\xf6\xfc\xc3\xe3\xd5\xf5\xc5\xe5\xd1\xf1\xc7\xe7\xba\xaa\x8e\x9e\x9d\x8d\xd8\xf8\x8a\x9a";
   $alpha = 'AEIOUYaeiouyAEIOUaeiouACENUrcenuAEIOUaedouAaOoLlNnCcsSZztTRrSs';
   $url = strtr($url, $noalpha, $alpha);
   $url = strtolower($url);
   $url = preg_replace('~[^a-z0-9_]+~', '-', $url);
   $url = trim($url, "-");
   $url = preg_replace('~[^-a-z0-9_]+~', '', $url);
   echo $url."\n";
   return $url;
}
//projde všechny výrobky v db
@$spojeni = MySQL_Connect('SERVER' ,'USER', 'PASSWORD');
@MySQL_Select_DB('DATABASE');
if (!$spojeni):
 echo "MySQL fatal error (no database)";
endif;
mysql_query("SET CHARACTER SET utf8");
$sql = "select id_product, name, id_lang from ps_product_lang";
$query = mysql_query($sql);
$num = mysql_num_rows($query);
while ($row=mysql_fetch_assoc($query)):
 $url = friendly_url($row['name']);
 $sql2 = "update ps_product_lang set link_rewrite = '$url' where id_product = {$row['id_product']} and id_lang = {$row['id_lang']}";
 mysql_query($sql2) or die("SQL dotaz nešlo provést");
endwhile;
echo "OK";
?>

 

ale musi se asi spoustet pri kazde uprave produktu, lepsi by to bylo vyresene primo v kodu pri uprave nebo pridavani produktu

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...