1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
store_product.php
См. документацию.
1<?php
2
3require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/catalog/general/store_product.php");
4
6{
7 public static function Add($arFields)
8 {
9 global $DB;
10
11 foreach(GetModuleEvents("catalog", "OnBeforeStoreProductAdd", true) as $arEvent)
12 {
13 if (ExecuteModuleEventEx($arEvent, [&$arFields]) === false)
14 {
15 return false;
16 }
17 }
18
19 if (!static::CheckFields('ADD',$arFields))
20 {
21 return false;
22 }
23
24 $arInsert = $DB->PrepareInsert("b_catalog_store_product", $arFields);
25 $strSql = "INSERT INTO b_catalog_store_product (".$arInsert[0].") VALUES(".$arInsert[1].")";
26
27 $res = $DB->Query($strSql, true);
28 if(!$res)
29 {
30 return false;
31 }
32
33 $lastId = (int)$DB->LastID();
34
35 foreach(GetModuleEvents("catalog", "OnStoreProductAdd", true) as $arEvent)
36 {
38 }
39
40 return $lastId;
41 }
42
51 public static function GetList($arOrder = array(), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
52 {
53 global $DB;
55 "ID" => array("FIELD" => "CP.ID", "TYPE" => "int"),
56 "PRODUCT_ID" => array("FIELD" => "CP.PRODUCT_ID", "TYPE" => "int"),
57 "STORE_ID" => array("FIELD" => "CP.STORE_ID", "TYPE" => "int"),
58 "AMOUNT" => array("FIELD" => "CP.AMOUNT", "TYPE" => "double"),
59 "QUANTITY_RESERVED" => ["FIELD" => "CP.QUANTITY_RESERVED", "TYPE" => "double"],
60 "STORE_NAME" => array("FIELD" => "CS.TITLE", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"),
61 "STORE_ADDR" => array("FIELD" => "CS.ADDRESS", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"),
62 "STORE_DESCR" => array("FIELD" => "CS.DESCRIPTION", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"),
63 "STORE_GPS_N" => array("FIELD" => "CS.GPS_N", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"),
64 "STORE_GPS_S" => array("FIELD" => "CS.GPS_S", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"),
65 "STORE_IMAGE" => array("FIELD" => "CS.IMAGE_ID", "TYPE" => "int", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"),
66 "STORE_LOCATION" => array("FIELD" => "CS.LOCATION_ID", "TYPE" => "int", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)"),
67 "STORE_PHONE" => array("FIELD" => "CS.PHONE", "TYPE" => "string", "FROM" => "RIGHT JOIN b_catalog_store CS ON (CS.ID = CP.STORE_ID)")
68 );
69 $arSqls = CCatalog::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
70 $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
71
72 if (empty($arGroupBy) && is_array($arGroupBy))
73 {
74 $strSql = "SELECT ".$arSqls["SELECT"]." FROM b_catalog_store_product CP ".$arSqls["FROM"];
75 if (!empty($arSqls["WHERE"]))
76 $strSql .= " WHERE ".$arSqls["WHERE"];
77 if (!empty($arSqls["GROUPBY"]))
78 $strSql .= " GROUP BY ".$arSqls["GROUPBY"];
79
80 $dbRes = $DB->Query($strSql);
81 if ($arRes = $dbRes->Fetch())
82 return $arRes["CNT"];
83 else
84 return false;
85 }
86 $strSql = "SELECT ".$arSqls["SELECT"]." FROM b_catalog_store_product CP ".$arSqls["FROM"];
87 if (!empty($arSqls["WHERE"]))
88 $strSql .= " WHERE ".$arSqls["WHERE"];
89 if (!empty($arSqls["GROUPBY"]))
90 $strSql .= " GROUP BY ".$arSqls["GROUPBY"];
91 if (!empty($arSqls["ORDERBY"]))
92 $strSql .= " ORDER BY ".$arSqls["ORDERBY"];
93
94 $intTopCount = 0;
95 $boolNavStartParams = (!empty($arNavStartParams) && is_array($arNavStartParams));
96 if ($boolNavStartParams && array_key_exists('nTopCount', $arNavStartParams))
97 {
98 $intTopCount = intval($arNavStartParams["nTopCount"]);
99 }
100 if ($boolNavStartParams && 0 >= $intTopCount)
101 {
102 $strSql_tmp = "SELECT COUNT('x') as CNT FROM b_catalog_store_product CP ".$arSqls["FROM"];
103 if (!empty($arSqls["WHERE"]))
104 $strSql_tmp .= " WHERE ".$arSqls["WHERE"];
105 if (!empty($arSqls["GROUPBY"]))
106 $strSql_tmp .= " GROUP BY ".$arSqls["GROUPBY"];
107
108 $dbRes = $DB->Query($strSql_tmp);
109 $cnt = 0;
110 if (empty($arSqls["GROUPBY"]))
111 {
112 if ($arRes = $dbRes->Fetch())
113 $cnt = $arRes["CNT"];
114 }
115 else
116 {
117 $cnt = $dbRes->SelectedRowsCount();
118 }
119
120 $dbRes = new CDBResult();
121
122 $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
123 }
124 else
125 {
126 if ($boolNavStartParams && 0 < $intTopCount)
127 {
128 $strSql .= " LIMIT ".$intTopCount;
129 }
130 $dbRes = $DB->Query($strSql);
131 }
132 return $dbRes;
133 }
134}
static PrepareSql(&$arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields)
Определения catalog.php:389
static Add($arFields)
Определения store_product.php:7
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения store_product.php:51
if(!\Bitrix\Main\Loader::includeModule('clouds')) $lastId
Определения sync.php:68
$arFields
Определения dblapprove.php:5
</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
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
$arRes
Определения options.php:104
$arFilter
Определения user_search.php:106
$dbRes
Определения yandex_detail.php:168