The zd_user_id is our customer custom attribute.
$customerCollection = $this->customerFactory->create();
$customers = $customerCollection->addAttributeToFilter(
[
['attribute' => 'zd_user_id', 'null' => true],
['attribute' => 'zd_user_id', 'eq' => ''],
['attribute' => 'zd_user_id', 'eq' => 'NO FIELD']
],
'',
'left'
)
How could I get all customers with the attribute zd_user_id equal true via SQL?
asked Oct 27, 2020 at 15:49
Rafael Corrêa Gomes
13.9k15 gold badges92 silver badges190 bronze badges
1 Answer 1
select * from eav_attribute where attribute_code='zd_user_id';
from this query, you get the attribute id and you also get the backend_type for this attribute.
Assuming the backend type is int.
select count(*) from customer_entity_int where attribute_id=<attribute_id_found> and value=1;
If it's varchar you can change the query to search in the table
customer_entity_varchar.
Rafael Corrêa Gomes
13.9k15 gold badges92 silver badges190 bronze badges
answered Oct 27, 2020 at 20:22
Herve Tribouilloy
7,7962 gold badges15 silver badges29 bronze badges
default