I am having product collection where I am getting one custom product attribute called "keep_disabled" and another column which was added on runtime which is sum of quantities 'sum_qty'. I just want to get the product collection where keep disable is true and sum of quantity is greater than 0. I can filter out the quantity by :
$collection->getSelect()->having('sum_qty > 0');
but I also want to add filter :
$collection->addAttributeToFilter('keep_disabled', array(array('neq' => 1) , array('eq' => 0),array('null' => true)));
I only want those products where (if keep disable is false, don't check the quantity) and (if keep disable is true, get only those products where quantity is greater than 0); so basically don't want to show those products where keep disable is true and quantity is 0.