{"id":2890,"date":"2013-04-30T09:44:13","date_gmt":"2013-04-30T09:44:13","guid":{"rendered":"https:\/\/www.infomeik.com\/?p=2890"},"modified":"2022-04-07T17:46:12","modified_gmt":"2022-04-07T17:46:12","slug":"quitar-es-o-idioma-predefinido-de-la-url-amigable-de-prestashop","status":"publish","type":"post","link":"https:\/\/www.infomeik.com\/en\/quitar-es-o-idioma-predefinido-de-la-url-amigable-de-prestashop\/","title":{"rendered":"Remove\/ es \/(or\/ language \/ default) from the Prestashop friendly URL"},"content":{"rendered":"<p>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 &#8221; getLangLink&#8221;:<\/p>\n<p>[php] term br \/&gt; if (!$id_lang){<br \/>\nif(Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id) == $context-&gt;language-&gt;id)<br \/>\nreturn &#8220;;<br \/>\n}<br \/>\nelse{<br \/>\nif($id_lang == Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id))<br \/>\nreturn &#8220;;<br \/>\n}<br \/>\n[\/php]<\/p>\n<p>Leaving the function like this:<\/p>\n<p>[php]<br \/>\ngetlanglink protected function ($id_lang = null, context of $context = null)<br \/>\n{<br \/>\nif (!$context)<br \/>\n$context = Context::getContext();<\/p>\n<p>if (!$this &#8211; &gt; allow || !Language: isMultiLanguageActivated() )<br \/>\nreturn &#8220;;<\/p>\n<p>if(!$id_lang){<br \/>\nif(Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id) == $context-&gt;language-&gt;id)<br \/>\nreturn &#8220;;<br \/>\n}<br \/>\nelse{<br \/>\nif($id_lang == Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id))<br \/>\nreturn &#8220;;<br \/>\n}<br \/>\nif (!$id_lang) term br \/ &gt; $id_lang = $context &#8211; &gt;language &#8211; &gt; id; term br \/ &gt; return language:: getsobyid ($id_lang).&#8217;\/&#8217;;<\/p>\n<p>}<br \/>\n[\/php]<\/p>\n<p>We must also modify the Switchlanguage function of the Tools class in\/classes \/ Tools.adding php:<\/p>\n<p>[php]<br \/>\n&#8230;<br \/>\nelse<br \/>\n$_GET[&#8216;id_lang&#8217;] = (int)Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id);<br \/>\n&#8230;<br \/>\n[\/php]<\/p>\n<p>Leaving the function like this:<\/p>\n<p>[php] term br \/&gt; public static function switchLanguage (Context $context = null) term br \/ &gt; {term br \/&gt; if (!$context)<br \/>\n$context = Context::getContext();<\/p>\n<p>\/\/ Install call the dispatcher and so the switchLanguage<br \/>\n\/\/ Stop this method by checking the cookie<br \/>\nif (!isset($context-&gt;cookie))<br \/>\nreturn;<\/p>\n<p>if (($iso = Tools::getValue(&#8216;isolang&#8217;)) &amp;&amp; Validate::isLanguageIsoCode($iso) &amp;&amp; ($id_lang = (int)Language: getIdByIso($iso)))<br \/>\n$_GET[&#8216;id_lang&#8217;] = $id_lang;<br \/>\nelse<br \/>\n$_GET[&#8216;id_lang&#8217;] = (int)Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id);<\/p>\n<p>\/\/ update the language only if the new id is different from the old id<br \/>\n\/\/ or if the default language changed<br \/>\n$cookie_id_lang = $context-&gt;cookie-&gt;id_lang;<br \/>\n$configuration_id_lang = Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;);<br \/>\nif ((($id_lang = (int)Tools::getValue(&#8216;id_lang&#8217;)) &amp;&amp; Validate::isUnsignedId($id_lang) &amp;&amp; $cookie_id_lang != (int)$id_lang)<br \/>\n|| (($id_lang == $configuration_id_lang) &amp;&amp; Validate::isUnsignedId($id_lang) &amp;&amp; $id_lang != $cookie_id_lang))<br \/>\n{<br \/>\n$context-&gt;cookie-&gt;id_lang = $id_lang;<br \/>\n$language = new Language($id_lang);<br \/>\nif (Validate::isLoadedObject($language))<br \/>\n$context-&gt;language = $language;<\/p>\n<p>$params = $_GET;<br \/>\nif (Configuration::get(&#8216;PS_REWRITING_SETTINGS&#8217;) || !Language: isMultiLanguageActivated())<br \/>\nunset($params[&#8216;id_lang&#8217;]);<br \/>\n}<br \/>\n}<br \/>\n[\/php]<\/p>","protected":false},"excerpt":{"rendered":"<p>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 &#8221; getLangLink&#8221;: [php] term br \/&gt; if (!$id_lang){ if(Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id) == $context-&gt;language-&gt;id) return &#8220;; } else{ if($id_lang == Configuration::get(&#8216;PS_LANG_DEFAULT&#8217;, null, $shop-&gt;id_shop_group, $shop-&gt;id)) return &#8220;; } [\/php] Leaving the function like this: [php]<\/p>\n<div class=\"h10\"><\/div>\n<p><a class=\"more-link2 flat\" href=\"https:\/\/www.infomeik.com\/en\/quitar-es-o-idioma-predefinido-de-la-url-amigable-de-prestashop\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[46],"tags":[],"class_list":["post-2890","post","type-post","status-publish","format-standard","hentry","category-programacion-prestashop"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/posts\/2890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/comments?post=2890"}],"version-history":[{"count":2,"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/posts\/2890\/revisions"}],"predecessor-version":[{"id":25680,"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/posts\/2890\/revisions\/25680"}],"wp:attachment":[{"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/media?parent=2890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/categories?post=2890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infomeik.com\/en\/wp-json\/wp\/v2\/tags?post=2890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}