Answer the question
In order to leave comments, you need to log in
How to get all products from the section Store-Reports-Products?
How to get a list of products for a month from the Shop-Products-Reports section without using the bitrix:sale.bestsellers component.
First did this:
CModule::IncludeModule("sale");
$arFilter = [];
$date = new DateTime();
$date->modify("-4 week");
$month_earlier = $date->getTimestamp();
$arFilter = [">=DATE_INSERT" => date($DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")), $month_earlier)];
$db_sales = CSaleOrder::GetList([], $arFilter);
$arOrders = [];
while ($ar_sales = $db_sales->Fetch()) {
$arOrders[] = $ar_sales['ID'];
}
if (count($arOrders)) {
$dbBasketItems = CSaleBasket::GetList([], ["ORDER_ID" => $arOrders, 'ORDER_PAYED' => 'Y'], false, false, []);
$arTopItems = [];
while ($arItem = $dbBasketItems->Fetch()) {
$arr[] = $arItem['NAME'];
$arTopItems[$arItem['PRODUCT_ID']] += 1;
}
arsort($arTopItems);
print_r($arTopItems);
$arTopItems = array_slice($arTopItems, 0, 50, true);
foreach($arTopItems as $k => $v){
$keys[] = $k;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question