I don't know why this:

$attributeCollection = Mage::getResourceModel('myext/attributelist_collection')
//$attributeCollection = Mage::getModel('myext/attributelist')->getCollection()
    ->addFieldToFilter('to_export', array('eq' => 1))
    ->getSelect()->order('order DESC');

Isn't working, when the query I get with __getSelect() is correct and works when I execute it directly in the console.

The line commented is another try that doesn't work.

any idea?

  • Is that any error show when you try above code? – Dhiren Vasoya Oct 30 '17 at 13:49

Once you call getSelect(), it'll return a Zend_Db_Select object instead of a Magento collection.

Break it into two statements: one for getting the collection, and the second for adding custom sql expressions. Try this:

$attributeCollection = Mage::getResourceModel('myext/attributelist_collection')
    ->addFieldToFilter('to_export', array('eq' => 1));

$attributeCollection->getSelect()->order('order DESC');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.