[-] Core: Fix language link with multishop from another shop #PSCFV-10063
This commit is contained in:
1 parent
cecaee8e68
commit
3d591be8c6
3 files changed
+26
-20
No files matched your search
@@ -549,6 +549,9 @@ class DispatcherCore
|
|||||||
if ($id_shop === null)
|
if ($id_shop === null)
|
||||||
$id_shop = (int)Context::getContext()->shop->id;
|
$id_shop = (int)Context::getContext()->shop->id;
|
||||||
|
|
||||||
|
if ($this->use_routes && !isset($this->routes[$id_shop]))
|
||||||
|
$this->loadRoutes($id_shop);
|
||||||
|
|
||||||
if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id]))
|
if (!isset($this->routes[$id_shop]) || !isset($this->routes[$id_shop][$id_lang]) || !isset($this->routes[$id_shop][$id_lang][$route_id]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -70,7 +70,7 @@ class LanguageCore extends ObjectModel
|
|||||||
/** @var array Languages cache */
|
/** @var array Languages cache */
|
||||||
protected static $_checkedLangs;
|
protected static $_checkedLangs;
|
||||||
protected static $_LANGUAGES;
|
protected static $_LANGUAGES;
|
||||||
protected static $countActiveLanguages;
|
protected static $countActiveLanguages = array();
|
||||||
|
|
||||||
protected $webserviceParameters = array(
|
protected $webserviceParameters = array(
|
||||||
'objectNodeName' => 'language',
|
'objectNodeName' => 'language',
|
||||||
@@ -762,15 +762,18 @@ class LanguageCore extends ObjectModel
|
|||||||
return (isset(self::$_cache_language_installation[$iso_code]) ? self::$_cache_language_installation[$iso_code] : false);
|
return (isset(self::$_cache_language_installation[$iso_code]) ? self::$_cache_language_installation[$iso_code] : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function countActiveLanguages()
|
public static function countActiveLanguages($id_shop = null)
|
||||||
{
|
{
|
||||||
if (!self::$countActiveLanguages)
|
if ($id_shop === null)
|
||||||
self::$countActiveLanguages = Db::getInstance()->getValue('
|
$id_shop = (int)Context::getContext()->shop->id;
|
||||||
|
|
||||||
|
if (!isset(self::$countActiveLanguages[$id_shop]))
|
||||||
|
self::$countActiveLanguages[$id_shop] = Db::getInstance()->getValue('
|
||||||
SELECT COUNT(DISTINCT l.id_lang) FROM `'._DB_PREFIX_.'lang` l
|
SELECT COUNT(DISTINCT l.id_lang) FROM `'._DB_PREFIX_.'lang` l
|
||||||
'.Shop::addSqlAssociation('lang', 'l').'
|
JOIN '._DB_PREFIX_.'lang_shop lang_shop ON (lang_shop.id_lang = l.id_lang AND lang_shop.id_shop = '.(int)$id_shop.')
|
||||||
WHERE l.`active` = 1
|
WHERE l.`active` = 1
|
||||||
');
|
');
|
||||||
return self::$countActiveLanguages;
|
return self::$countActiveLanguages[$id_shop];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null)
|
public static function downloadAndInstallLanguagePack($iso, $version = null, $params = null)
|
||||||
@@ -825,8 +828,8 @@ class LanguageCore extends ObjectModel
|
|||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isMultiLanguageActivated()
|
public static function isMultiLanguageActivated($id_shop = null)
|
||||||
{
|
{
|
||||||
return (Language::countActiveLanguages() > 1);
|
return (Language::countActiveLanguages($id_shop) > 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-12
@@ -96,14 +96,14 @@ class LinkCore
|
|||||||
else
|
else
|
||||||
$shop = Context::getContext()->shop;
|
$shop = Context::getContext()->shop;
|
||||||
|
|
||||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||||
|
|
||||||
if (!is_object($product))
|
if (!is_object($product))
|
||||||
{
|
{
|
||||||
if (is_array($product) && isset($product['id_product']))
|
if (is_array($product) && isset($product['id_product']))
|
||||||
$product = new Product($product['id_product'], false, $id_lang);
|
$product = new Product($product['id_product'], false, $id_lang, $id_shop);
|
||||||
elseif ((int)$product)
|
elseif ((int)$product)
|
||||||
$product = new Product((int)$product, false, $id_lang);
|
$product = new Product((int)$product, false, $id_lang, $id_shop);
|
||||||
else
|
else
|
||||||
throw new PrestaShopException('Invalid product vars');
|
throw new PrestaShopException('Invalid product vars');
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ class LinkCore
|
|||||||
$shop = Context::getContext()->shop;
|
$shop = Context::getContext()->shop;
|
||||||
else
|
else
|
||||||
$shop = new Shop($id_shop);
|
$shop = new Shop($id_shop);
|
||||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||||
|
|
||||||
if (!is_object($category))
|
if (!is_object($category))
|
||||||
$category = new Category($category, $id_lang);
|
$category = new Category($category, $id_lang);
|
||||||
@@ -210,7 +210,7 @@ class LinkCore
|
|||||||
$shop = Context::getContext()->shop;
|
$shop = Context::getContext()->shop;
|
||||||
else
|
else
|
||||||
$shop = new Shop($id_shop);
|
$shop = new Shop($id_shop);
|
||||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||||
|
|
||||||
$dispatcher = Dispatcher::getInstance();
|
$dispatcher = Dispatcher::getInstance();
|
||||||
if (!is_object($cms_category))
|
if (!is_object($cms_category))
|
||||||
@@ -250,7 +250,7 @@ class LinkCore
|
|||||||
$shop = Context::getContext()->shop;
|
$shop = Context::getContext()->shop;
|
||||||
else
|
else
|
||||||
$shop = new Shop($id_shop);
|
$shop = new Shop($id_shop);
|
||||||
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||||
|
|
||||||
|
|
||||||
$dispatcher = Dispatcher::getInstance();
|
$dispatcher = Dispatcher::getInstance();
|
||||||
@@ -294,7 +294,7 @@ class LinkCore
|
|||||||
$shop = Context::getContext()->shop;
|
$shop = Context::getContext()->shop;
|
||||||
else
|
else
|
||||||
$shop = new Shop($id_shop);
|
$shop = new Shop($id_shop);
|
||||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||||
|
|
||||||
$dispatcher = Dispatcher::getInstance();
|
$dispatcher = Dispatcher::getInstance();
|
||||||
if (!is_object($supplier))
|
if (!is_object($supplier))
|
||||||
@@ -331,7 +331,7 @@ class LinkCore
|
|||||||
$shop = Context::getContext()->shop;
|
$shop = Context::getContext()->shop;
|
||||||
else
|
else
|
||||||
$shop = new Shop($id_shop);
|
$shop = new Shop($id_shop);
|
||||||
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
$url = 'http://'.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||||
|
|
||||||
$dispatcher = Dispatcher::getInstance();
|
$dispatcher = Dispatcher::getInstance();
|
||||||
if (!is_object($manufacturer))
|
if (!is_object($manufacturer))
|
||||||
@@ -371,7 +371,7 @@ class LinkCore
|
|||||||
$shop = Context::getContext()->shop;
|
$shop = Context::getContext()->shop;
|
||||||
else
|
else
|
||||||
$shop = new Shop($id_shop);
|
$shop = new Shop($id_shop);
|
||||||
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang);
|
$url = $base.$shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop);
|
||||||
|
|
||||||
// If the module has its own route ... just use it !
|
// If the module has its own route ... just use it !
|
||||||
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop))
|
if (Dispatcher::getInstance()->hasRoute('module-'.$module.'-'.$controller, $id_lang, $id_shop))
|
||||||
@@ -476,7 +476,7 @@ class LinkCore
|
|||||||
|
|
||||||
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request, false, '', $id_shop);
|
$uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request, false, '', $id_shop);
|
||||||
$url = ($ssl && $this->ssl_enable) ? 'https://' : 'http://';
|
$url = ($ssl && $this->ssl_enable) ? 'https://' : 'http://';
|
||||||
$url .= $shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang).ltrim($uri_path, '/');
|
$url .= $shop->domain.$shop->getBaseURI().$this->getLangLink($id_lang, null, $id_shop).ltrim($uri_path, '/');
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
@@ -629,12 +629,12 @@ class LinkCore
|
|||||||
return $url.(!strstr($url, '?') ? '?' : '&').'orderby='.urlencode($orderby).'&orderway='.urlencode($orderway);
|
return $url.(!strstr($url, '?') ? '?' : '&').'orderby='.urlencode($orderby).'&orderway='.urlencode($orderway);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getLangLink($id_lang = null, Context $context = null)
|
protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null)
|
||||||
{
|
{
|
||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
|
|
||||||
if (!$this->allow || !Language::isMultiLanguageActivated())
|
if (!$this->allow || !Language::isMultiLanguageActivated($id_shop))
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
if (!$id_lang)
|
if (!$id_lang)
|
||||||
|
|||||||
Reference in new issue
Block a user