1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
product.php
См. документацию.
1<?php
2
3
4namespace Bitrix\Sale\Rest\Synchronization\Loader;
5
6use Bitrix\Main\ArgumentException;
7use Bitrix\Main\Entity\DataManager;
8use Bitrix\Main\Loader;
9use Bitrix\Sale\Registry;
10
11class Product extends Entity
12{
14 {
15 $result = array();
16
17 Loader::includeModule('iblock');
18 Loader::includeModule('catalog');
19
20 $iblockIds = [];
22 'select' => ['IBLOCK_ID'],
23 'filter' => ['=IBLOCK.ACTIVE'=>'Y']
24 ]);
25 while ($res = $row->fetch())
26 $iblockIds[] = $res['IBLOCK_ID'];
27
28 //TODO: необходимо переделать на вызов метода каталога, который на вход полчучает произвольный product_xml_id и возвращает продукт каталога.
29 if (empty($iblockIds))
30 {
31 // nothing here
32 }
33 else
34 {
35 $r = \CIBlockElement::GetList(array(),
36 array("=XML_ID" => $code, "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y", "IBLOCK_ID"=>$iblockIds),
37 false,
38 false,
39 array("ID", "IBLOCK_ID", "XML_ID", "NAME", "DETAIL_PAGE_URL")
40 );
41 if($ar = $r->GetNext())
42 {
43 $result = $ar;
44 $product = \CCatalogProduct::GetByID($ar["ID"]);
45
46 $result["WEIGHT"] = $product["WEIGHT"];
47 $result["CATALOG_GROUP_NAME"] = $product["CATALOG_GROUP_NAME"];
48
49 $productIBlock = static::getIBlockProduct($ar["IBLOCK_ID"]);
50 $result["IBLOCK_XML_ID"] = $productIBlock[$ar["IBLOCK_ID"]]["XML_ID"];
51 }
52 }
53
54 return $result;
55 }
56
58 {
59 $result = '';
60
61 if(mb_strpos($code, '#') !== false)
62 {
63 $code = explode('#', $code);
64 $result = $code[1];
65 }
66 return $result;
67 }
68
69 private static function getIBlockProduct($iblockId)
70 {
71 static $iblock_fields = null;
72
73 if($iblock_fields[$iblockId] == null)
74 {
75 $r = \CIBlock::GetList(array(), array("ID" => $iblockId));
76 if ($ar = $r->Fetch())
77 $iblock_fields[$iblockId] = $ar;
78 }
79 return $iblock_fields;
80 }
81}
static getList(array $parameters=array())
Определения datamanager.php:431
static GetByID($ID)
Определения product.php:625
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$iblockId
Определения iblock_catalog_edit.php:30
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$ar
Определения options.php:199