if CModule IncludeModule sale arSort array arSelect array ID NAME PROP

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
if (CModule::IncludeModule("sale"))
{
$arSort = array();
$arSelect = array(
"ID",
"NAME",
"PROPERTY_NAIMENOVANIE_DLYA_SAYTA_POLNOE"
);
$arFilter = array(
"IBLOCK_ID" => CATALOG_IBLOCK_ID_KS,
"ID" => $id
);
$rsElements = CIBlockElement::GetList(
$arSort,
$arFilter,
false,
false,
$arSelect
);
$arElement = $rsElements->GetNext();
$arFields = array(
'PRODUCT_ID' => $productId,
'PRODUCT_PRICE_ID' => 0,
'PRICE' => 0.00,
'CURRENCY' => 'RUB',
'WEIGHT' => 0,
'QUANTITY' => !empty($quantity) ? $quantity : 1,
'LID' => SITE_ID,
'DELAY' => 'N',
'CAN_BUY' => 'Y',
'NAME' => $arElement["PROPERTY_NAIMENOVANIE_DLYA_SAYTA_POLNOE_VALUE"],
'MODULE' => 'catalog',
);
$arProps = array();
$arProps[] = array(
"NAME" => 'Арктикул',
"CODE" => 'CML2_ARTICLE',
"VALUE" => htmlspecialcharsEx($_REQUEST['product_props']['articul']),
"SORT" => 100
);
$arFields["PROPS"] = $arProps;
$sb = new CSaleBasket;
if($sb->Add($arFields))
{
$result['status'] = 1;
}
else
{
$result['status'] = 0;
if($ex = $APPLICATION->GetException())
$result['error'] = $ex->GetString();
}
}
else
{
$result['error'] = "Не подключен модуль catalog";
}