Jump to content

how can change the order of language flags? in 1.5.6


matteosalvati

Recommended Posts

there is an sql query:

		$sql = 'SELECT l.*, ls.`id_shop`
				FROM `'._DB_PREFIX_.'lang` l
				LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)';

it's necessary to add there ORDER BY clause,

something like:

		$sql = 'SELECT l.*, ls.`id_shop`
				FROM `'._DB_PREFIX_.'lang` l
				LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang) 
                ORDER BY l.name DESC
                ';
  • Like 1
Link to comment
Share on other sites

public static function loadLanguages()

{

self::$_LANGUAGES = array();

 

$sql = 'SELECT l.*, ls.`id_shop`

FROM `'._DB_PREFIX_.'lang` l

LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)';

ORDER BY l.name DESC;

 

$result = Db::getInstance()->executeS($sql);

foreach ($result as $row)

{

if (!isset(self::$_LANGUAGES[(int)$row['id_lang']]))

self::$_LANGUAGES[(int)$row['id_lang']] = $row;

self::$_LANGUAGES[(int)$row['id_lang']]['shops'][(int)$row['id_shop']] = true;

}

}

Link to comment
Share on other sites

well, now work! i ordered by id_lang and now is the order that i want!

 

 

public static function loadLanguages()

{

self::$_LANGUAGES = array();

 

$sql = 'SELECT l.*, ls.`id_shop`

FROM `'._DB_PREFIX_.'lang` l

LEFT JOIN `' . _DB_PREFIX_ . 'lang_shop` ls ON (l.id_lang = ls.id_lang)

ORDER BY l.id_lang DESC' ;

 

$result = Db::getInstance()->executeS($sql);

foreach ($result as $row)

{

if (!isset(self::$_LANGUAGES[(int)$row['id_lang']]))

self::$_LANGUAGES[(int)$row['id_lang']] = $row;

self::$_LANGUAGES[(int)$row['id_lang']]['shops'][(int)$row['id_shop']] = true;

}

}

 

more thanks
Link to comment
Share on other sites

  • 2 months later...

hi, i tried change the query, but doesn't work, try cleaning the cache of prestashop, and the browser but not success.

 

My query is correct:

 

$sql = 'SELECT l.*, ls.`id_shop, l.name`
FROM `'._DB_PREFIX_.'lang` l
LEFT JOIN `'._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang) ORDER BY l.name';
 
But doesn't work, i tried to run this query directly in MYSQL and it worked, but in the PHP of prestashop don't worked.
 
Can help me?
Link to comment
Share on other sites

This work:

 

$sql = 'SELECT l.*, ls.`id_shop`
                FROM `'
._DB_PREFIX_.'lang` l
                LEFT JOIN `'
._DB_PREFIX_.'lang_shop` ls ON (l.id_lang = ls.id_lang)
ORDER BY l.name DESC
'
;

 

 

 

maybe you forgot DESC or ASC?

 

 
 
Link to comment
Share on other sites

so i bet that your theme displays languages based on different queries, or even on different module.

are you 100% sure that your theme uses default block languages block? and that .tpl file of this addon uses the same code as original one?

Link to comment
Share on other sites

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...