Jump to content

[SOLVED] Display Tags Block in alphabetical order


intandem

Recommended Posts

For 1.5.3.1 edit the file /classes/Tag.php

 

find the function getMainTags :

 

 

public static function getMainTags($id_lang, $nb = 10)

{

$groups = FrontController::getCurrentCustomerGroups();

$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');

 

return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('

SELECT t.name, COUNT(pt.id_tag) AS times

FROM `'._DB_PREFIX_.'product_tag` pt

LEFT JOIN `'._DB_PREFIX_.'tag` t ON (t.id_tag = pt.id_tag)

LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = pt.id_product)

'.Shop::addSqlAssociation('product', 'p').'

WHERE t.`id_lang` = '.(int)$id_lang.'

AND product_shop.`active` = 1

AND product_shop.`id_product` IN (

SELECT cp.`id_product`

FROM `'._DB_PREFIX_.'category_group` cg

LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)

WHERE cg.`id_group` '.$sql_groups.'

)

GROUP BY t.id_tag

ORDER BY t.name ASC

LIMIT 0, '.(int)$nb);

}

 

Change red text. Save. Reload page

 

(If it doesn't do anything, maybe you need to go to Advanced Parameters -> Perfornamce and in the smarty section change the folowing options:

set to force compilation

cache to off

 

then reload page with tags block and see it it works.

(N.B. Don't forget to change the smarty settings back after you're finished trying! Otherwise your site will slowdown...)

 

Didn't try it, but I expect this to work. Give it a try and let us know.

 

Hope this helps,

Pascal

Link to comment
Share on other sites

  • 4 weeks later...
  • 8 months later...
  • 1 month later...

Hi Tomzie, soory for delayed response. Extremely busy lately...

 

I expect:

ORDER BY t.id_tag ASC

should do the ordering bu tag id.

 

Where exactly do you need the tag-order in back office?

pascal

 

If I could order them in back office: catalogue / tags  (some like position ordering of products sorted by category in catalogue/products)

 

But then I would have to 'order by position' in front office.

 

 

That would be awesome!  :lol: 

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