I added 'custom_field' to 'customer_entity' table by using 'db_schema.xml' file and need to save 'some value' in it then I wanted to filter the collection by 'custom_field' value. How can I achieve this ? When I use the below code.

$customer = $this->_customerFactory->create();
$customerData = $customer->getCollection()->addAttributeToFilter('custom_field',array('neq'=>'cleared'))->setOrder('entity_id','ASC')->load();

I am getting this error : The "custom_field" attribute name is invalid. Reset the name and try again.


1 Answer 1


You should try using addFieldToFilter instead of addAttributeToFilter because you are working with the database table field rather than a customer attribute.

Please try it once:

$customer = $this->_customerFactory->create();
$customerData = $customer->getCollection()->addFieldToFilter('custom_field',array('neq'=>'cleared'))->setOrder('entity_id','ASC')->load();

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.