/** * Returns product data. * * @param array &$productData Product data. * @param array $entityData Entity data. * @param array $iblockData Iblock list data. * @return void */ protected static function getProductData(&$productData, $entityData, $iblockData) { if (!empty($iblockData['iblockElement'])) { $productList = array_keys($productData); if (!empty($entityData['iblockFields'])) { $elementIterator = Iblock\ElementTable::getList(array('select' => array_merge(array('ID'), array_keys($entityData['iblockFields'])), 'filter' => array('@ID' => $productList))); while ($element = $elementIterator->fetch()) { $element['ID'] = (int) $element['ID']; $fields = array(); foreach ($entityData['iblockFields'] as $key => $alias) { $fields[$alias] = $element[$key]; } unset($key, $alias); $productData[$element['ID']] = empty($productData[$element['ID']]) ? $fields : array_merge($productData[$element['ID']], $fields); unset($fields); } } if ($entityData['sections']) { $productSection = array_fill_keys($productList, array()); $elementSectionIterator = Iblock\SectionElementTable::getList(array('select' => array('*'), 'filter' => array('@IBLOCK_ELEMENT_ID' => $productList))); while ($elementSection = $elementSectionIterator->fetch()) { $elementSection['IBLOCK_ELEMENT_ID'] = (int) $elementSection['IBLOCK_ELEMENT_ID']; $elementSection['IBLOCK_SECTION_ID'] = (int) $elementSection['IBLOCK_SECTION_ID']; $elementSection['ADDITIONAL_PROPERTY_ID'] = (int) $elementSection['ADDITIONAL_PROPERTY_ID']; if ($elementSection['ADDITIONAL_PROPERTY_ID'] > 0) { continue; } $productSection[$elementSection['IBLOCK_ELEMENT_ID']][$elementSection['IBLOCK_SECTION_ID']] = true; $parentSectionIterator = \CIBlockSection::getNavChain(0, $elementSection['IBLOCK_SECTION_ID'], array('ID')); while ($parentSection = $parentSectionIterator->fetch()) { $parentSection['ID'] = (int) $parentSection['ID']; $productSection[$elementSection['IBLOCK_ELEMENT_ID']][$parentSection['ID']] = true; } unset($parentSection, $parentSectionIterator); } unset($elementSection, $elementSectionIterator); foreach ($productSection as $element => $sections) { $productData[$element]['SECTION_ID'] = array_keys($sections); } unset($element, $sections, $productSection); } if (!empty($entityData['needProperties'])) { $propertyValues = array_fill_keys($productList, array()); foreach ($entityData['needProperties'] as $iblock => $propertyList) { if (empty($iblockData['iblockElement'][$iblock])) { continue; } $filter = array('ID' => $iblockData['iblockElement'][$iblock], 'IBLOCK_ID' => $iblock); \CTimeZone::disable(); \CIBlockElement::getPropertyValuesArray($propertyValues, $iblock, $filter, array('ID' => $propertyList)); \CTimeZone::enable(); } unset($filter, $iblock, $propertyList); self::convertProperties($productData, $propertyValues, $entityData, $iblockData); } if (!empty($entityData['catalogFields'])) { $productIterator = Catalog\ProductTable::getList(array('select' => array_merge(array('ID'), array_keys($entityData['catalogFields'])), 'filter' => array('@ID' => $productList))); while ($product = $productIterator->fetch()) { $product['ID'] = (int) $product['ID']; $fields = array(); foreach ($entityData['catalogFields'] as $key => $alias) { $fields[$alias] = $product[$key]; } unset($key, $alias); $productData[$product['ID']] = empty($productData[$product['ID']]) ? $fields : array_merge($productData[$product['ID']], $fields); unset($fields); } unset($product, $productIterator); } if (!empty($iblockData['skuIblockList'])) { self::getParentProducts($productData, $entityData, $iblockData); } } }
$rsMaster->SetUrlTemplates($arParams['DETAIL_URL']); $arMaster = $rsMaster->GetNext(); unset($rsMaster); if (empty($arMaster)) { $found = false; } else { $arMaster['NAME'] = $arElement['NAME']; $arElement = $arMaster; } unset($arMaster); } } } if ($found) { $sectionsList = array(); $sectionsIterator = Iblock\SectionElementTable::getList(array('select' => array('IBLOCK_SECTION_ID'), 'filter' => array('=IBLOCK_ELEMENT_ID' => $arElement['ID'], '=ADDITIONAL_PROPERTY_ID' => null))); while ($section = $sectionsIterator->fetch()) { $sectionId = (int) $section['IBLOCK_SECTION_ID']; $sectionsList[$sectionId] = $sectionId; } unset($section, $sectionsIterator); $_SESSION[$arParams['NAME']][$arParams['IBLOCK_ID']]['ITEMS'][$productID] = array('ID' => $arElement['ID'], '~ID' => $arElement['~ID'], 'IBLOCK_ID' => $arElement['IBLOCK_ID'], '~IBLOCK_ID' => $arElement['~IBLOCK_ID'], 'IBLOCK_SECTION_ID' => $arElement['IBLOCK_SECTION_ID'], '~IBLOCK_SECTION_ID' => $arElement['~IBLOCK_SECTION_ID'], 'NAME' => $arElement['NAME'], '~NAME' => $arElement['~NAME'], 'DETAIL_PAGE_URL' => $arElement['DETAIL_PAGE_URL'], '~DETAIL_PAGE_URL' => $arElement['~DETAIL_PAGE_URL'], 'SECTIONS_LIST' => $sectionsList, 'PARENT_ID' => $productID, 'DELETE_URL' => htmlspecialcharsbx($APPLICATION->GetCurPageParam($arParams['ACTION_VARIABLE'] . "=DELETE_FROM_COMPARE_RESULT&" . $arParams['PRODUCT_ID_VARIABLE'] . "=" . $productID, array($arParams['ACTION_VARIABLE'], $arParams['PRODUCT_ID_VARIABLE'])))); unset($sectionsList, $arElement); $resultCount = count($_SESSION[$arParams['NAME']][$arParams['IBLOCK_ID']]['ITEMS']); } else { $successfulAction = false; $errorMessage = GetMessage('CP_BCCR_ERR_MESS_PRODUCT_NOT_FOUND'); } } if ($actionByAjax) { if ($successfulAction) {