• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/inheritedproperty/elementvalues.php
  • Класс: BitrixIblockInheritedPropertyElementValues
  • Вызов: ElementValues::queryValues
public function queryValues()
{
	$connection = BitrixMainApplication::getConnection();
	$result = array();
	if ($this->hasTemplates())
	{
		if ($this->queue->getElement($this->iblockId, $this->elementId) === false)
		{
			$ids = $this->queue->get($this->iblockId);
			$query = $connection->query("
				SELECT
					P.ID
					,P.CODE
					,P.TEMPLATE
					,P.ENTITY_TYPE
					,P.ENTITY_ID
					,IP.VALUE
					,IP.ELEMENT_ID
				FROM
					b_iblock_element_iprop IP
					INNER JOIN b_iblock_iproperty P ON P.ID = IP.IPROP_ID
				WHERE
					IP.IBLOCK_ID = ".$this->iblockId."
					AND IP.ELEMENT_ID in (".implode(", ", $ids).")
			");
			$result = array();
			while ($row = $query->fetch())
			{
				$result[$row["ELEMENT_ID"]][$row["CODE"]] = $row;
			}
			$this->queue->set($this->iblockId, $result);
		}
		$result = $this->queue->getElement($this->iblockId, $this->elementId);

		if (empty($result))
		{
			$result = parent::queryValues();
			if (!empty($result))
			{
				$sqlHelper = $connection->getSqlHelper();
				$elementList = BitrixIblockElementTable::getList(array(
					"select" => array("IBLOCK_SECTION_ID"),
					"filter" => array("=ID" => $this->elementId),
				));
				$element = $elementList->fetch();
				$element['IBLOCK_SECTION_ID'] = (int)$element['IBLOCK_SECTION_ID'];

				$fields = array(
					"IBLOCK_ID",
					"SECTION_ID",
					"ELEMENT_ID",
					"IPROP_ID",
					"VALUE",
				);
				$rows = array();
				foreach ($result as $CODE => $row)
				{
					$rows[] = array(
						$this->iblockId,
						$element["IBLOCK_SECTION_ID"],
						$this->elementId,
						$row["ID"],
						$sqlHelper->forSql($row["VALUE"]),
					);
				}
				$this->insertValues("b_iblock_element_iprop", $fields, $rows);
			}
		}
	}
	return $result;
}