Jump to content

[blocklayered] Problem with def sorting


miodek

Recommended Posts

Hi

 

I have a category tree like this one (it's just an example)

 

Cars (top cat)

red cars (sub cat)

blue cars (sub cat)

orange cars (sub cat)

 

When i navigate to Cars cat all products from subcats show (and that is ok ) but they are in wierd order.

First a red car shows, then a blue car and so (not like in the back office in cars main cat).

 

I would like them to show in a order like in the back office - where the Cars main cat has a product list sorted corectly.

 

I've located the query in blocklayered.php

 

Line 2495

 

  SELECT
p.*,
'.($alias_where == 'p' ? '' : 'product_shop.*,' ).'
'.$alias_where.'.id_category_default,
pl.*,
i.id_image,
il.legend,
m.name manufacturer_name,
DATEDIFF('.$alias_where.'.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
  FROM `'._DB_PREFIX_.'category_product` cp
  LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category)
  LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
  '.$join.'
  LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product)
  LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
  LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = '.(int)($cookie->id_lang).')
  LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
  WHERE '.$alias_where.'.`active` = 1 AND
  '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.'
  AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).'
  AND c.active = 1
  AND pl.id_lang = '.(int)$cookie->id_lang.'
  AND p.id_product IN ('.implode(',', $product_id_list).')'
  .' GROUP BY p.id_product ORDER BY '.Tools::getProductsOrder('by', Tools::getValue('orderby'), true).' '.Tools::getProductsOrder('way', Tools::getValue('orderway')).

 

 

Tried to mix with ORDER BY and some Joins but no luck ( i know i have to kill the sorting option but that is ok for me). Can please somebody help ?

Link to comment
Share on other sites

Im sorry but this is not the problem.

 

Cars (top cat)

red cars (sub cat)

blue cars (sub cat)

orange cars (sub cat)

 

It shoud look more like

 

Class (top cat)

girls (sub cat)

boys (sub cat)

teachers (sub cat)

 

And when i go to Class category it shows :

1 girl, 1 boy, 1 teacher and so

 

But in my back office in the Class category i have it in a diffrent order like this:

1 girl, 1 girl , 1 girl, 1 teacher

 

Thanks for trying to help!

Edited by miodek (see edit history)
Link to comment
Share on other sites

  • 1 month later...

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