What is the best way to load Customer by custom attribute?
I create custom module. What should I overwrite?
- Model/Customer
- Model/ResourceModel/Customer
- Model/ResourceModel/CustomerRepository
What is the best way?
customermagento-2.1magento2
What is the best way to load Customer by custom attribute?
I create custom module. What should I overwrite?
What is the best way?
Best Answer
We should try with Service Contracts Layer.
Take a look:
vendor/magento/module-backend/Model/Search/Customer::load()
We can use
Magento\Customer\Api\CustomerRepositoryInterface::getList()
to retrieve customers which match a specified criteria.