1С-Битрикс
- 77 ответов
- 0 вопросов
77
Вклад в тег
$elements = [];
CModule::IncludeModule("catalog");
$my_slider = CIBlockElement::GetList (
Array("NAME" => "ASC"),
Array("IBLOCK_ID" => 1),
false,
false,
Array(
'ID',
'NAME',
)
);
while($ar_fields = $my_slider->GetNext())
{
$elements[] = $ar_fields;
}
$productID = array_column($elements, 'ID');
$arSKU = CCatalogSKU::getOffersList(
$productID,
0,
array('ACTIVE' => 'Y'),
array('ID', 'NAME', 'CODE'),
array()
);
foreach ($elements as $element) {
echo $element['NAME'] . '</br>';
if ($arSKU[$element['ID']]) {
foreach ($arSKU[$element['ID']] as $offer) {
echo $offer['CODE'] . '<br>';
}
}
}
function InstallEvents()
{
RegisterModuleDependences('search', 'BeforeIndex', 'mymodule.smartsearch', '\\MyModule\\SmartSearch\\EventHandler', 'BeforeIndex');
}
function UnInstallEvents()
{
UnRegisterModuleDependences('search', 'BeforeIndex', 'mymodule.smartsearch', '\\MyModule\\SmartSearch\\EventHandler', 'BeforeIndex');
}
namespace MyModule\SmartSearch;
class EventHandler
{
function BeforeIndex($arFields)
{
\CModule::IncludeModule("iblock");
if ($arFields["MODULE_ID"] == "iblock") {
$result = \CIBlockElement::GetByID($arFields["ITEM_ID"]);
if ($element = $result->Fetch()) {
$arFields['PARAM1'] = $element['IBLOCK_SECTION_ID'];
}
}
return $arFields;
}
}