Last active
May 27, 2020 15:51
-
-
Save BedrosovaYulia/8d19b8139facc6c18033459cbb65a4fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
#With DB Query | |
global $DB; | |
$phones = $DB->Query("SELECT * FROM `b_crm_field_multi` WHERE TYPE_ID='PHONE' AND VALUE='".$phone."'"); | |
while($row = $phones->fetch()) | |
{ | |
} | |
$emails = $DB->Query("SELECT * FROM `b_crm_field_multi` WHERE TYPE_ID='EMAIL' AND VALUE='".$email."'"); | |
while($row = $emails->fetch()) | |
{ | |
} | |
?> | |
<? | |
#With API | |
use \Bitrix\Main; | |
use \Bitrix\Crm; | |
/* @var string Email, который будем искать */ | |
$sEmail = '[email protected]'; | |
/* @var array ID лидов, которые попадаются под условия */ | |
$arLeadIds = []; | |
if ( Main\Loader::IncludeModule('crm') ) | |
{ | |
// Формируем критерий, подсовываем Email | |
$criterion = new Crm\Integrity\DuplicateCommunicationCriterion( Crm\CommunicationType::EMAIL_NAME, $sEmail); | |
// Выполняем поиск первых 20 клиентов | |
$duplicate = $criterion->find( \CCrmOwnerType::Contact, 2); | |
// Если найдены entity проитерируем их | |
$entities = $duplicate->getEntities(); | |
if ( !empty($entities) ) | |
{ | |
foreach($entities as $entity) | |
{ | |
$arLeadIds[] = $entity->getEntityID(); | |
} | |
} | |
} | |
print_r($arLeadIds[0]); | |
?> | |
<? | |
CModule::IncludeModule('crm'); | |
$rsContact = CCrmFieldMulti::GetList( | |
array(), | |
array( | |
'ENTITY_ID' => 'CONTACT', // looking for only on contacts | |
"VALUE" => $sEmail, | |
) | |
); | |
if($arContact = $rsContact->Fetch()) | |
{ | |
AddMessage2Log($arContact['ELEMENT_ID'], "first_finded_contact_id"); | |
$ContactID=$arContact['ELEMENT_ID']; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment