2

I want to achieve the following query in magento custom model.

select * form calendar where date >='2015-04-13' AND start_date <='2015-04-14' AND (is_available != 1 or  (is_available == 1 and rooms_avil<=0))

How to achieve this in magento with AddFieldToFilter ? Not AddAttributeToFilter.

1 Answer 1

1

Method addAttributeToFilter is used for module whose model supports EAV structure like: catalog/category, catalog/product etc. We generally use addFieldToFitler for custom module (whose model doesn’t support EAV structure)

Answering on your question: how to create

condition OR (condition AND condition)

I think you can't do it using addFieldToFilter. So my advice is:

->getSelect()->where( /* put here all of your conditions */)

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.