How to print raw SQL query by applying filters on searchCriteriaBuilder ?

I am using the following method, but it's giving error: "Uncaught Error: Call to undefined method Magento\Framework\Api\Search\SearchCriteriaBuilder::getSelect()"

echo $this->searchCriteriaBuilder->addFilters($searchCriteria)->getSelect();

Please help.

1 Answer 1


The searchCriteriaBuilder does not create an sql query itself.

But instead it just defines an array of criteria to be applied to the colleciton.

In order to see the sql query being formed after the searchCriteriaBuilder is applied you have to use getSelect() in your collection


Also you can print the criteria applied by your searchCriteriaBuilder by using this


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.