Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sql = [
- 'select' => [
- "ID",
- ],
- 'runtime' => [
- new \Bitrix\Main\Entity\ReferenceField( // получим свойство связи с SKU
- 'CML2_LINK',
- '\Bitrix\Iblock\PropertyTable',
- [
- "=ref.CODE" => new \Bitrix\Main\DB\SqlExpression('?', 'CML2_LINK'),
- ],
- ["join_type" => "left"]
- ),
- new \Bitrix\Main\Entity\ReferenceField( // получим свойство артикула
- 'CML2_ARTICLE',
- '\Bitrix\Iblock\PropertyTable',
- [
- "=ref.CODE" => new \Bitrix\Main\DB\SqlExpression('?', 'CML2_ARTICLE'),
- ],
- ["join_type" => "left"]
- ),
- new \Bitrix\Main\Entity\ReferenceField( // получим свойство штрихкода
- 'CML2_BAR_CODE',
- '\Bitrix\Iblock\PropertyTable',
- [
- "=ref.CODE" => new \Bitrix\Main\DB\SqlExpression('?', 'CML2_BAR_CODE'),
- ],
- ["join_type" => "left"]
- ),
- new \Bitrix\Main\Entity\ReferenceField(
- 'SKU_LINK_ID',
- '\Bitrix\Iblock\ElementPropertyTable',
- [
- "=this.ID" => "ref.VALUE",
- "=this.CML2_LINK.ID" => "ref.IBLOCK_PROPERTY_ID",
- ],
- ["join_type" => "inner"]
- ),
- new \Bitrix\Main\Entity\ReferenceField(
- 'SKU_ITEM',
- '\Bitrix\Iblock\ElementTable',
- [
- "=this.SKU_LINK_ID.IBLOCK_ELEMENT_ID" => "ref.ID",
- ],
- ["join_type" => "left"]
- ),
- new \Bitrix\Main\Entity\ReferenceField(
- 'SKU_ITEM_PROPERTY_CML2_ARTICLE',
- '\Bitrix\Iblock\ElementPropertyTable',
- [
- "=this.SKU_ITEM.ID" => "ref.IBLOCK_ELEMENT_ID",
- "=this.CML2_ARTICLE.ID" => "ref.IBLOCK_PROPERTY_ID",
- ],
- ["join_type" => "left"]
- ),
- new \Bitrix\Main\Entity\ReferenceField(
- 'SKU_ITEM_PROPERTY_CML2_BAR_CODE',
- '\Bitrix\Iblock\ElementPropertyTable',
- [
- "=this.SKU_ITEM.ID" => "ref.IBLOCK_ELEMENT_ID",
- "=this.CML2_BAR_CODE.ID" => "ref.IBLOCK_PROPERTY_ID",
- ],
- ["join_type" => "left"]
- ),
- new \Bitrix\Main\Entity\ReferenceField(
- 'SECTION',
- '\Bitrix\Iblock\SectionTable',
- [
- "=this.IBLOCK_SECTION_ID" => "ref.ID",
- ],
- ["join_type" => "left"]
- ),
- new \Bitrix\Main\Entity\ReferenceField(
- 'TOP_SECTION',
- '\Bitrix\Iblock\SectionTable',
- [
- ">this.SECTION.LEFT_MARGIN" => "ref.LEFT_MARGIN",
- "<this.SECTION.RIGHT_MARGIN" => "ref.RIGHT_MARGIN",
- "=ref.DEPTH_LEVEL" => new \Bitrix\Main\DB\SqlExpression('?', '1'),
- ],
- ["join_type" => "left"]
- ),
- ],
- 'group' => [
- 'ID',
- //'SKU_ITEM.ID',
- ],
- 'filter' => [
- "ACTIVE" => "Y",
- "IBLOCK_ID" => $arParams["IBLOCK_ID"], // только товары
- "!=TOP_SECTION.CODE" => $_SESSION["SKIP_INDEX_SECTION_CODE"],
- ],
- 'order' => ['ID' => "ASC"],
- 'cache' => ($arParams["CACHE_TYPE"] != "N" ? ["ttl" => $arParams["CACHE_TIME"], "cache_joins" => true] : null),
- 'limit' => 50000
- ];
- $iterator = \Bitrix\Iblock\ElementTable::getList($sql);
- while ($filtredElementArr = $iterator->fetch()) {
- $ids[] = $filtredElementArr["ID"];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement