php - Magento, sort by YES/NO attribute -


i have load collection of products , sort them further display.

originally collection sorted date. works flawlessly. had add new yes/no attribute products. worked out great well.

the thing wasn't able figure out how sort collection attribute. collection have sorted new attribute date.

i thought work:

$collection->addattributetoselect('name');  $collection->addattributetoselect('yesnoattr');  $collection->addattributetoselect('special_to_date');  $collection->addattributetoselect('short_description');  $collection->addattributetoselect('image');  $collection->addattributetosort('yesnoattr', 'asc')->addattributetosort('special_to_date', 'asc');  $products = $collection->load(); 

it doesn't. tried set order:

$collection->setorder('yesnoattr','asc'); 

i tried sorting new attribute, didn't work either, i'm pretty sure has nothing me trying sort 2 attributes.

i trying solve hours , i'm clueless i'm doing wrong.

any appreciated.

to add more 1 attribute order can try this:

$collection->getselect()->order('main_table.yesnoattr asc')         ->order('main_table.special_to_date asc'); 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -