Skip to content

Instantly share code, notes, and snippets.

@anoriar
Created November 13, 2018 15:43
Show Gist options
  • Save anoriar/74bf3816bf98a82a8cacef7257fc99dc to your computer and use it in GitHub Desktop.
Save anoriar/74bf3816bf98a82a8cacef7257fc99dc to your computer and use it in GitHub Desktop.
getDetailPageResHl
/**
* На вход принимает элементы (товары или тп) + массив свойств-привязок к справочникам
* На выходе: подробные данные элементов по этим справочникам
* Важно! для бриллианта в массиве $arPropCodes может быть только STONES_ATTACH
* @param $items
* @param $arProps
*/
public function getDetailPageResHL($items, $arPropCodes){
//массив из элементов с значениями свойств, привязанных к hl
$itemsHlPropValues = [];
foreach($items as $itemId => $item){
foreach($arPropCodes as $code){
if(!empty($item["PROPERTIES"][$code]["VALUE"]))
$itemsHlPropValues[$itemId][$code] = $item["PROPERTIES"][$code]["VALUE"];
}
}
$resHl = [];
$productsInst = Products::getInstanceByCode();
$props = $productsInst->getProperties(
[
"select" => ["ID", "IBLOCK_ID", "CODE", "PROPERTY_TYPE", "USER_TYPE_SETTINGS", "USER_TYPE"],
"filter" => ["CODE" => $arPropCodes, "IBLOCK_ID" => IB_Catalog]
]
);
foreach ($props as $prop) {
if($prop["USER_TYPE"] == "directory") {
$arPropData = unserialize($prop["USER_TYPE_SETTINGS"]);
$tableName = $arPropData["TABLE_NAME"];
}
}
// TODO:дописать
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment