0

I am trying to add where in collection but it return

Varien_Db_Select Object

instead of return collection object.

$collection = Mage::getModel('orderoutofuk/orderitem')->getCollection()->getSelect()->where('main_table.send_payment_request_date >= DATE(NOW()) - INTERVAL 7 DAY ');

and I want specific column value in array instead of looping through each object.

1 Answer 1

1

You should try with below code it will give you collection object.

$collection = Mage::getModel('orderoutofuk/orderitem')->getCollection()->addFieldToFilter("send_payment_request_date", array('gteq'=>new Zend_Db_Expr('DATE(NOW()) - INTERVAL 7 DAY')));

and then you can use getColumnValues function on collection to get values in form of single dimension array without looping throug each object.

$collection = Mage::getModel('orderoutofuk/orderitem')->getCollection()->addFieldToFilter("send_payment_request_date", array('gteq'=>new Zend_Db_Expr('DATE(NOW()) - INTERVAL 7 DAY')))->getColumnValues('<YourFieldName>');

It will return like

    Array
(
    [0] => 'Your value'
    [1] => 'Your value'
)

Your Answer

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

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