I am trying to get customer collection based on email_id and my custom customer attributes i.e phone_code and mobile_number.
When I only add email filter getList return's customer array object but when I add my custom filter of mobile_number and phone_code attribute it return's 0 element error.
So is there any way we can use custom customer attributes in Search Criteria.
My Sample code:
$customerRepository = $this->_customerRepositoryInterface;
$email[] = $this->_filterBuilder
->setField('email')
->setValue($row[5])
->setConditionType('eq')
->create();
$phonecode[] = $this->_filterBuilder
->setField('phone_code')
->setValue($row[7])
->setConditionType('eq')
->create();
$mobile[] = $this->_filterBuilder
->setField('mobile_number')
->setValue($row[11])
->setConditionType('eq')
->create();
$searchCriteria = $this->_searchCriteriaBuilder
->addFilters($email)
->addFilters($phonecode)
->addFilters($mobile)
->create();
$customerCollection = $customerRepository->getList($searchCriteria)->getItems();
Solved! Go to Solution.
It is working fine, sorry its was my variable and customers data which is not exist that is why its returning 0 exception.
@Agarwal Aman Did you get any solutions ? I have same issue with my product interface. Please help if you get any alternate solutions or anything.