A
A
Alexer052019-01-25 08:07:08
1C-Bitrix
Alexer05, 2019-01-25 08:07:08

How to show users who made purchases in the last 2 years through the Bitrix API?

How to show users who made purchases in the last 2 years through the Bitrix API?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
ArmBar, 2019-01-25
@Alexer05

\Bitrix\Main\Loader::includeModule('sale');
$date = new \Bitrix\Main\Type\Date();
$date->add('-2 year');

$userDataByOrders = \Bitrix\Sale\Order::getList([
    'filter' => ['>DATE_INSERT' => $date->toString()],
    'select' => ['USER_ID', 'USER_INFO_' => 'USER'],
    'group' => ['USER_ID']
]);

$userData = $userDataByOrders->fetchAll();

S
Suitcase Bezrukov, 2019-01-25
@Chemodanbezruk

Get a list of orders for the last 2 years. Get an array of user ids from it. Make CUser::GetList filter by id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question