0

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?

1
  • Is that any error show when you try above code? Oct 30, 2017 at 13:49

1 Answer 1

0

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');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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