I have a query for calculating the minimal price. The select statement part is:

IF(at_price_index.tier_price IS NOT NULL, LEAST(at_price_index.min_price, at_price_index.tier_price), at_price_index.min_price) AS theprice

How can I add the following where clause?

where theprice = 10

I have tried the following code:

$myProductCollection->addFieldToFilter('theprice', '10');

But I get an error:

Fatal error: Call to a member function getBackend() on a non-object


Try with

$myProductCollection->getSelect()->having('theprice = ?', 10);

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.