Remove/ es /(or/ language / default) from the Prestashop friendly URL

This modification was made in Prestashop 1.5.3.1. Suppose it can work for the entire 1.5 branch.x of Prestashop. In the file /classes/Link.php we modify the function ” getLangLink”:

[php] term br /> if (!$id_lang){
if(Configuration::get(‘PS_LANG_DEFAULT’, null, $shop->id_shop_group, $shop->id) == $context->language->id)
return “;
}
else{
if($id_lang == Configuration::get(‘PS_LANG_DEFAULT’, null, $shop->id_shop_group, $shop->id))
return “;
}
[/php]

Leaving the function like this:

[php]
getlanglink protected function ($id_lang = null, context of $context = null)
{
if (!$context)
$context = Context::getContext();

if (!$this – > allow || !Language: isMultiLanguageActivated() )
return “;

if(!$id_lang){
if(Configuration::get(‘PS_LANG_DEFAULT’, null, $shop->id_shop_group, $shop->id) == $context->language->id)
return “;
}
else{
if($id_lang == Configuration::get(‘PS_LANG_DEFAULT’, null, $shop->id_shop_group, $shop->id))
return “;
}
if (!$id_lang) term br / > $id_lang = $context – >language – > id; term br / > return language:: getsobyid ($id_lang).’/’;

}
[/php]

We must also modify the Switchlanguage function of the Tools class in/classes / Tools.adding php:

[php]

else
$_GET[‘id_lang’] = (int)Configuration::get(‘PS_LANG_DEFAULT’, null, $shop->id_shop_group, $shop->id);

[/php]

Leaving the function like this:

[php] term br /> public static function switchLanguage (Context $context = null) term br / > {term br /> if (!$context)
$context = Context::getContext();

// Install call the dispatcher and so the switchLanguage
// Stop this method by checking the cookie
if (!isset($context->cookie))
return;

if (($iso = Tools::getValue(‘isolang’)) && Validate::isLanguageIsoCode($iso) && ($id_lang = (int)Language: getIdByIso($iso)))
$_GET[‘id_lang’] = $id_lang;
else
$_GET[‘id_lang’] = (int)Configuration::get(‘PS_LANG_DEFAULT’, null, $shop->id_shop_group, $shop->id);

// update the language only if the new id is different from the old id
// or if the default language changed
$cookie_id_lang = $context->cookie->id_lang;
$configuration_id_lang = Configuration::get(‘PS_LANG_DEFAULT’);
if ((($id_lang = (int)Tools::getValue(‘id_lang’)) && Validate::isUnsignedId($id_lang) && $cookie_id_lang != (int)$id_lang)
|| (($id_lang == $configuration_id_lang) && Validate::isUnsignedId($id_lang) && $id_lang != $cookie_id_lang))
{
$context->cookie->id_lang = $id_lang;
$language = new Language($id_lang);
if (Validate::isLoadedObject($language))
$context->language = $language;

$params = $_GET;
if (Configuration::get(‘PS_REWRITING_SETTINGS’) || !Language: isMultiLanguageActivated())
unset($params[‘id_lang’]);
}
}
[/php]