Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
product.php
1<?php
2namespace Bitrix\Catalog;
3
7
63{
64 public const USER_FIELD_ENTITY_ID = 'PRODUCT';
65
66 public const STATUS_YES = 'Y';
67 public const STATUS_NO = 'N';
68 public const STATUS_DEFAULT = 'D';
69
70 public const TYPE_PRODUCT = 1;
71 public const TYPE_SET = 2;
72 public const TYPE_SKU = 3;
73 public const TYPE_OFFER = 4;
74 public const TYPE_FREE_OFFER = 5;
75 public const TYPE_EMPTY_SKU = 6;
76 public const TYPE_SERVICE = 7;
77
78 public const PAYMENT_TYPE_SINGLE = 'S';
79 public const PAYMENT_TYPE_REGULAR = 'R';
80 public const PAYMENT_TYPE_TRIAL = 'T';
81
82 public const PAYMENT_PERIOD_HOUR = 'H';
83 public const PAYMENT_PERIOD_DAY = 'D';
84 public const PAYMENT_PERIOD_WEEK = 'W';
85 public const PAYMENT_PERIOD_MONTH = 'M';
86 public const PAYMENT_PERIOD_QUART = 'Q';
87 public const PAYMENT_PERIOD_SEMIYEAR = 'S';
88 public const PAYMENT_PERIOD_YEAR = 'Y';
89 public const PAYMENT_PERIOD_DOUBLE_YEAR = 'T';
90
91 public const PRICE_MODE_SIMPLE = 'S';
92 public const PRICE_MODE_QUANTITY = 'Q';
93 public const PRICE_MODE_RATIO = 'R';
94
95 protected static array $defaultProductSettings = [];
96
102 public static function getTableName(): string
103 {
104 return 'b_catalog_product';
105 }
106
112 public static function getMap(): array
113 {
114 return [
115 'ID' => new Main\Entity\IntegerField(
116 'ID',
117 [
118 'primary' => true,
119 'title' => Loc::getMessage('PRODUCT_ENTITY_ID_FIELD'),
120 ]
121 ),
122 'QUANTITY' => new Main\Entity\FloatField(
123 'QUANTITY',
124 [
125 'default_value' => 0,
126 'title' => Loc::getMessage('PRODUCT_ENTITY_QUANTITY_FIELD'),
127 ]
128 ),
129 'QUANTITY_TRACE' => new Main\Entity\EnumField(
130 'QUANTITY_TRACE',
131 [
132 'values' => [
133 self::STATUS_DEFAULT,
134 self::STATUS_NO,
135 self::STATUS_YES,
136 ],
137 'default_value' => self::STATUS_DEFAULT,
138 'fetch_data_modification' => [__CLASS__, 'modifyQuantityTrace'],
139 'title' => Loc::getMessage('PRODUCT_ENTITY_QUANTITY_TRACE_FIELD_MSGVER_1'),
140 ]
141 ),
142 'QUANTITY_TRACE_ORIG' => new Main\Entity\ExpressionField(
143 'QUANTITY_TRACE_ORIG',
144 '%s',
145 'QUANTITY_TRACE',
146 [
147 'data_type' => 'string',
148 ]
149 ),
150 'WEIGHT' => new Main\Entity\FloatField(
151 'WEIGHT',
152 [
153 'default_value' => 0,
154 'title' => Loc::getMessage('PRODUCT_ENTITY_WEIGHT_FIELD'),
155 ]
156 ),
157 'TIMESTAMP_X' => new Main\Entity\DatetimeField(
158 'TIMESTAMP_X',
159 [
160 'default_value' => function()
161 {
162 return new Main\Type\DateTime();
163 },
164 'title' => Loc::getMessage('PRODUCT_ENTITY_TIMESTAMP_X_FIELD'),
165 ]
166 ),
167 'PRICE_TYPE' => new Main\Entity\EnumField(
168 'PRICE_TYPE',
169 [
170 'values' => self::getPaymentTypes(false),
171 'default_value' => self::PAYMENT_TYPE_SINGLE,
172 'title' => Loc::getMessage('PRODUCT_ENTITY_PRICE_TYPE_FIELD'),
173 ]
174 ),
175 'RECUR_SCHEME_LENGTH' => new Main\Entity\IntegerField(
176 'RECUR_SCHEME_LENGTH',
177 [
178 'default_value' => 0,
179 'title' => Loc::getMessage('PRODUCT_ENTITY_RECUR_SCHEME_LENGTH_FIELD'),
180 ]
181 ),
182 'RECUR_SCHEME_TYPE' => new Main\Entity\EnumField(
183 'RECUR_SCHEME_TYPE',
184 [
185 'values' => self::getPaymentPeriods(false),
186 'default_value' => self::PAYMENT_PERIOD_DAY,
187 'title' => Loc::getMessage('PRODUCT_ENTITY_RECUR_SCHEME_TYPE_FIELD'),
188 ]
189 ),
190 'TRIAL_PRICE_ID' => new Main\Entity\IntegerField(
191 'TRIAL_PRICE_ID',
192 [
193 'title' => Loc::getMessage('PRODUCT_ENTITY_TRIAL_PRICE_ID_FIELD'),
194 ]
195 ),
196 'WITHOUT_ORDER' => new Main\Entity\BooleanField(
197 'WITHOUT_ORDER',
198 [
199 'values' => [
200 self::STATUS_NO,
201 self::STATUS_YES,
202 ],
203 'default_value' => self::STATUS_NO,
204 'title' => Loc::getMessage('PRODUCT_ENTITY_WITHOUT_ORDER_FIELD'),
205 ]
206 ),
207 'SELECT_BEST_PRICE' => new Main\Entity\BooleanField(
208 'SELECT_BEST_PRICE',
209 [
210 'values' => [
211 self::STATUS_NO,
212 self::STATUS_YES,
213 ],
214 'default_value' => self::STATUS_YES,
215 ]
216 ),
217 'VAT_ID' => new Main\Entity\IntegerField(
218 'VAT_ID',
219 [
220 'default_value' => 0,
221 'title' => Loc::getMessage('PRODUCT_ENTITY_VAT_ID_FIELD'),
222 ]
223 ),
224 'VAT_INCLUDED' => new Main\Entity\BooleanField(
225 'VAT_INCLUDED',
226 [
227 'values' => [
228 self::STATUS_NO,
229 self::STATUS_YES,
230 ],
231 'default_value' => self::STATUS_NO,
232 'title' => Loc::getMessage('PRODUCT_ENTITY_VAT_INCLUDED_FIELD'),
233 ]
234 ),
235 'CAN_BUY_ZERO' => new Main\Entity\EnumField(
236 'CAN_BUY_ZERO',
237 [
238 'values' => [
239 self::STATUS_DEFAULT,
240 self::STATUS_NO,
241 self::STATUS_YES,
242 ],
243 'default_value' => self::STATUS_DEFAULT,
244 'fetch_data_modification' => [__CLASS__, 'modifyCanBuyZero'],
245 'title' => Loc::getMessage('PRODUCT_ENTITY_CAN_BUY_ZERO_FIELD'),
246 ]
247 ),
248 'CAN_BUY_ZERO_ORIG' => new Main\Entity\ExpressionField(
249 'CAN_BUY_ZERO_ORIG',
250 '%s',
251 'CAN_BUY_ZERO',
252 [
253 'data_type' => 'string',
254 ]
255 ),
256 'NEGATIVE_AMOUNT_TRACE' => new Main\Entity\EnumField(
257 'NEGATIVE_AMOUNT_TRACE',
258 [
259 'values' => [
260 self::STATUS_DEFAULT,
261 self::STATUS_NO,
262 self::STATUS_YES,
263 ],
264 'default_value' => self::STATUS_DEFAULT,
265 'fetch_data_modification' => [__CLASS__, 'modifyNegativeAmountTrace'],
266 'title' => Loc::getMessage('PRODUCT_ENTITY_NEGATIVE_AMOUNT_TRACE_FIELD'),
267 ]
268 ),
269 'NEGATIVE_AMOUNT_TRACE_ORIG' => new Main\Entity\ExpressionField(
270 'NEGATIVE_AMOUNT_TRACE_ORIG',
271 '%s',
272 'NEGATIVE_AMOUNT_TRACE',
273 [
274 'data_type' => 'string',
275 ]
276 ),
277 'TMP_ID' => New Main\Entity\StringField(
278 'TMP_ID',
279 [
280 'validation' => [__CLASS__, 'validateTmpId'],
281 'title' => Loc::getMessage('PRODUCT_ENTITY_TMP_ID_FIELD'),
282 ]
283 ),
284 'PURCHASING_PRICE' => new Main\Entity\FloatField(
285 'PURCHASING_PRICE',
286 [
287 'title' => Loc::getMessage('PRODUCT_ENTITY_PURCHASING_PRICE_FIELD'),
288 ]
289 ),
290 'PURCHASING_CURRENCY' => new Main\Entity\StringField(
291 'PURCHASING_CURRENCY',
292 [
293 'validation' => [__CLASS__, 'validatePurchasingCurrency'],
294 'title' => Loc::getMessage('PRODUCT_ENTITY_PURCHASING_CURRENCY_FIELD'),
295 ]
296 ),
297 'BARCODE_MULTI' => new Main\Entity\BooleanField(
298 'BARCODE_MULTI',
299 [
300 'values' => [
301 self::STATUS_NO,
302 self::STATUS_YES,
303 ],
304 'default_value' => self::STATUS_NO,
305 'title' => Loc::getMessage('PRODUCT_ENTITY_BARCODE_MULTI_FIELD'),
306 ]
307 ),
308 'QUANTITY_RESERVED' => new Main\Entity\FloatField(
309 'QUANTITY_RESERVED',
310 [
311 'title' => Loc::getMessage('PRODUCT_ENTITY_QUANTITY_RESERVED_FIELD'),
312 ]
313 ),
314 'SUBSCRIBE' => new Main\Entity\EnumField(
315 'SUBSCRIBE',
316 [
317 'values' => [
318 self::STATUS_DEFAULT,
319 self::STATUS_NO,
320 self::STATUS_YES,
321 ],
322 'default_value' => self::STATUS_DEFAULT,
323 'fetch_data_modification' => [__CLASS__, 'modifySubscribe'],
324 'title' => Loc::getMessage('PRODUCT_ENTITY_SUBSCRIBE_FIELD'),
325 ]
326 ),
327 'SUBSCRIBE_ORIG' => new Main\Entity\ExpressionField(
328 'SUBSCRIBE_ORIG',
329 '%s',
330 'SUBSCRIBE',
331 [
332 'data_type' => 'string',
333 ]
334 ),
335 'WIDTH' => new Main\Entity\FloatField(
336 'WIDTH',
337 [
338 'title' => Loc::getMessage('PRODUCT_ENTITY_WIDTH_FIELD'),
339 ]
340 ),
341 'LENGTH' => new Main\Entity\FloatField(
342 'LENGTH',
343 [
344 'title' => Loc::getMessage('PRODUCT_ENTITY_LENGTH_FIELD'),
345 ]
346 ),
347 'HEIGHT' => new Main\Entity\FloatField(
348 'HEIGHT',
349 [
350 'title' => Loc::getMessage('PRODUCT_ENTITY_HEIGHT_FIELD'),
351 ]
352 ),
353 'MEASURE' => new Main\Entity\IntegerField(
354 'MEASURE',
355 [
356 'title' => Loc::getMessage('PRODUCT_ENTITY_MEASURE_FIELD'),
357 ]
358 ),
359 'TYPE' => new Main\Entity\EnumField(
360 'TYPE',
361 [
362 'values' => [
363 self::TYPE_PRODUCT,
364 self::TYPE_SET,
365 self::TYPE_SKU,
366 self::TYPE_OFFER,
367 self::TYPE_FREE_OFFER,
368 self::TYPE_EMPTY_SKU,
369 self::TYPE_SERVICE,
370 ],
371 'default_value' => self::TYPE_PRODUCT,
372 'title' => Loc::getMessage('PRODUCT_ENTITY_TYPE_FIELD'),
373 ]
374 ),
375 'AVAILABLE' => new Main\Entity\BooleanField(
376 'AVAILABLE',
377 [
378 'values' => [
379 self::STATUS_NO,
380 self::STATUS_YES,
381 ],
382 'title' => Loc::getMessage('PRODUCT_ENTITY_AVAILABLE_FIELD'),
383 ]
384 ),
385 'BUNDLE' => new Main\Entity\BooleanField(
386 'BUNDLE',
387 [
388 'values' => [
389 self::STATUS_NO,
390 self::STATUS_YES,
391 ],
392 'title' => Loc::getMessage('PRODUCT_ENTITY_BUNDLE_FIELD'),
393 ]
394 ),
395 'IBLOCK_ELEMENT' => new Main\Entity\ReferenceField(
396 'IBLOCK_ELEMENT',
397 '\Bitrix\Iblock\Element',
398 [
399 '=this.ID' => 'ref.ID',
400 ],
401 [
402 'join_type' => 'LEFT',
403 ]
404 ),
405 'TRIAL_IBLOCK_ELEMENT' => new Main\Entity\ReferenceField(
406 'TRIAL_IBLOCK_ELEMENT',
407 '\Bitrix\Iblock\Element',
408 [
409 '=this.TRIAL_PRICE_ID' => 'ref.ID',
410 ],
411 [
412 'join_type' => 'LEFT',
413 ]
414 ),
415 'TRIAL_PRODUCT' => new Main\Entity\ReferenceField(
416 'TRIAL_PRODUCT',
417 '\Bitrix\Catalog\Product',
418 [
419 '=this.TRIAL_PRICE_ID' => 'ref.ID',
420 ],
421 [
422 'join_type' => 'LEFT',
423 ]
424 )
425 ];
426 }
427
433 public static function getUfId(): string
434 {
436 }
437
445 public static function validatePriceType()
446 {
447 return array();
448 }
449
457 public static function validateRecurSchemeType()
458 {
459 return array();
460 }
461
468 public static function validateTmpId()
469 {
470 return array(
471 new Main\Entity\Validator\Length(null, 40),
472 );
473 }
480 public static function validatePurchasingCurrency()
481 {
482 return array(
483 new Main\Entity\Validator\Length(null, 3),
484 );
485 }
486
493 public static function modifyQuantityTrace()
494 {
495 return array(
496 array(__CLASS__, 'prepareQuantityTrace')
497 );
498 }
499
506 public static function modifyCanBuyZero()
507 {
508 return array(
509 array(__CLASS__, 'prepareCanBuyZero')
510 );
511 }
512
519 public static function modifyNegativeAmountTrace()
520 {
521 return array(
522 array(__CLASS__, 'prepareNegativeAmountTrace')
523 );
524 }
525
532 public static function modifySubscribe()
533 {
534 return array(
535 array(__CLASS__, 'prepareSubscribe')
536 );
537 }
538
546 public static function prepareQuantityTrace($value)
547 {
548 if ($value == self::STATUS_DEFAULT)
549 {
550 if (empty(self::$defaultProductSettings))
552 return self::$defaultProductSettings['QUANTITY_TRACE'];
553 }
554 return $value;
555 }
556
564 public static function prepareCanBuyZero($value)
565 {
566 if ($value == self::STATUS_DEFAULT)
567 {
568 if (empty(self::$defaultProductSettings))
570 return self::$defaultProductSettings['CAN_BUY_ZERO'];
571 }
572 return $value;
573 }
574
582 public static function prepareNegativeAmountTrace($value)
583 {
584 if ($value == self::STATUS_DEFAULT)
585 {
586 if (empty(self::$defaultProductSettings))
588 return self::$defaultProductSettings['NEGATIVE_AMOUNT_TRACE'];
589 }
590 return $value;
591 }
592
600 public static function prepareSubscribe($value)
601 {
602 if ($value == self::STATUS_DEFAULT)
603 {
604 if (empty(self::$defaultProductSettings))
606 return self::$defaultProductSettings['SUBSCRIBE'];
607 }
608 return $value;
609 }
610
620 public static function isExistProduct($product)
621 {
622 $product = (int)$product;
623 if ($product <= 0)
624 return false;
625 $existProduct = self::getList(array(
626 'select' => array('ID'),
627 'filter' => array('=ID' => $product)
628 ))->fetch();
629 return (!empty($existProduct));
630 }
631
640 public static function clearProductCache($product = 0) {}
641
649 public static function getCurrentRatioWithMeasure($product)
650 {
651 if (!is_array($product))
652 $product = array($product);
653 Main\Type\Collection::normalizeArrayValuesByInt($product, true);
654 if (empty($product))
655 return false;
656
657 $result = array();
658
659 $defaultMeasure = \CCatalogMeasure::getDefaultMeasure(true, true);
660 $defaultRow = array(
661 'RATIO' => 1,
662 'MEASURE' => (!empty($defaultMeasure) ? $defaultMeasure : array())
663 );
664 $existProduct = array();
665 $measureMap = array();
666
667 $productRows = array_chunk($product, 500);
668 foreach ($productRows as &$row)
669 {
670 $productIterator = self::getList(array(
671 'select' => array('ID', 'MEASURE'),
672 'filter' => array('@ID' => $row),
673 'order' => array('ID' => 'ASC')
674 ));
675 while ($item = $productIterator->fetch())
676 {
677 $item['ID'] = (int)$item['ID'];
678 $item['MEASURE'] = (int)$item['MEASURE'];
679 $existProduct[] = $item['ID'];
680 $result[$item['ID']] = $defaultRow;
681 if ($item['MEASURE'] > 0)
682 {
683 if (!isset($measureMap[$item['MEASURE']]))
684 $measureMap[$item['MEASURE']] = array();
685 $measureMap[$item['MEASURE']][] = &$result[$item['ID']];
686 }
687 }
688 unset($item, $productIterator);
689 }
690 unset($row, $productRows);
691 unset($defaultRow, $defaultMeasure);
692 if (empty($existProduct))
693 return false;
694
695 $ratioResult = MeasureRatioTable::getCurrentRatio($existProduct);
696 if (!empty($ratioResult))
697 {
698 foreach ($ratioResult as $ratioProduct => $ratio)
699 $result[$ratioProduct]['RATIO'] = $ratio;
700 unset($ratio, $ratioProduct);
701 }
702 unset($ratioResult);
703 unset($existProduct);
704
705 if (!empty($measureMap))
706 {
707 $measureIterator = \CCatalogMeasure::getList(
708 array(),
709 array('@ID' => array_keys($measureMap)),
710 false,
711 false,
712 array()
713 );
714 while ($measure = $measureIterator->getNext())
715 {
716 $measure['ID'] = (int)$measure['ID'];
717 if (empty($measureMap[$measure['ID']]))
718 continue;
719
720 foreach ($measureMap[$measure['ID']] as &$product)
721 $product['MEASURE'] = $measure;
722 unset($product);
723 }
724 unset($measure, $measureIterator);
725 }
726 unset($measureMap);
727
728 return $result;
729 }
730
737 public static function calculateAvailable($fields)
738 {
739 if (empty($fields) || !is_array($fields))
740 {
741 return self::STATUS_NO;
742 }
743
744 if (isset($fields['QUANTITY']) && isset($fields['QUANTITY_TRACE']) && isset($fields['CAN_BUY_ZERO']))
745 {
746 if (empty(self::$defaultProductSettings))
747 {
749 }
750 if ($fields['QUANTITY_TRACE'] == self::STATUS_DEFAULT)
751 {
752 $fields['QUANTITY_TRACE'] = self::$defaultProductSettings['QUANTITY_TRACE'];
753 }
754 if ($fields['CAN_BUY_ZERO'] == self::STATUS_DEFAULT)
755 {
756 $fields['CAN_BUY_ZERO'] = self::$defaultProductSettings['CAN_BUY_ZERO'];
757 }
758
759 return (
760 (
761 (float)$fields['QUANTITY'] <= 0
762 && $fields['QUANTITY_TRACE'] == self::STATUS_YES
763 && $fields['CAN_BUY_ZERO'] == self::STATUS_NO
764 )
765 ? self::STATUS_NO
767 );
768 }
769
770 return self::STATUS_NO;
771 }
772
779 public static function isNeedCheckQuantity(array $fields): bool
780 {
781 if (isset($fields['QUANTITY_TRACE']) && isset($fields['CAN_BUY_ZERO']))
782 {
783 if (empty(self::$defaultProductSettings))
784 {
786 }
787 if ($fields['QUANTITY_TRACE'] == self::STATUS_DEFAULT)
788 {
789 $fields['QUANTITY_TRACE'] = self::$defaultProductSettings['QUANTITY_TRACE'];
790 }
791 if ($fields['CAN_BUY_ZERO'] == self::STATUS_DEFAULT)
792 {
793 $fields['CAN_BUY_ZERO'] = self::$defaultProductSettings['CAN_BUY_ZERO'];
794 }
795
796 return ($fields['QUANTITY_TRACE'] === self::STATUS_YES && $fields['CAN_BUY_ZERO'] === self::STATUS_NO);
797 }
798
799 return false;
800 }
801
808 public static function loadDefaultProductSettings()
809 {
810 self::$defaultProductSettings = [
811 'QUANTITY_TRACE' => (Main\Config\Option::get('catalog', 'default_quantity_trace') === 'Y' ? 'Y' : 'N'),
812 'CAN_BUY_ZERO' => (Main\Config\Option::get('catalog', 'default_can_buy_zero') === 'Y' ? 'Y' : 'N'),
813 'NEGATIVE_AMOUNT_TRACE' => (Main\Config\Option::get('catalog', 'allow_negative_amount') === 'Y' ? 'Y' : 'N'),
814 'SUBSCRIBE' => (Main\Config\Option::get('catalog', 'default_subscribe') === 'N' ? 'N' : 'Y'),
815 ];
816 }
817
824 public static function getProductTypes($descr = false)
825 {
826 if ($descr)
827 {
828 return [
829 self::TYPE_PRODUCT => Loc::getMessage('PRODUCT_ENTITY_TYPE_PRODUCT'),
830 self::TYPE_SET => Loc::getMessage('PRODUCT_ENTITY_TYPE_SET_MSGVER_1'),
831 self::TYPE_SKU => Loc::getMessage('PRODUCT_ENTITY_TYPE_SKU'),
832 self::TYPE_EMPTY_SKU => Loc::getMessage('PRODUCT_ENTITY_TYPE_EMPTY_SKU'),
833 self::TYPE_OFFER => Loc::getMessage('PRODUCT_ENTITY_TYPE_OFFER'),
834 self::TYPE_FREE_OFFER => Loc::getMessage('PRODUCT_ENTITY_TYPE_FREE_OFFER'),
835 self::TYPE_SERVICE => Loc::getMessage('PRODUCT_ENTITY_TYPE_SERVICE'),
836 ];
837 }
838 return [
846 ];
847 }
848
855 public static function getPaymentTypes($descr = false)
856 {
857 if ($descr)
858 {
859 return array(
860 self::PAYMENT_TYPE_SINGLE => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_TYPE_SINGLE'),
861 self::PAYMENT_TYPE_REGULAR => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_TYPE_REGULAR'),
862 self::PAYMENT_TYPE_TRIAL => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_TYPE_TRIAL')
863 );
864 }
865 return array(
866 self::PAYMENT_TYPE_SINGLE,
867 self::PAYMENT_TYPE_REGULAR,
868 self::PAYMENT_TYPE_TRIAL
869 );
870 }
871
878 public static function getPaymentPeriods($descr = false)
879 {
880 if ($descr)
881 {
882 return [
883 self::PAYMENT_PERIOD_HOUR => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_PERIOD_HOUR'),
884 self::PAYMENT_PERIOD_DAY => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_PERIOD_DAY'),
885 self::PAYMENT_PERIOD_WEEK => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_PERIOD_WEEK'),
886 self::PAYMENT_PERIOD_MONTH => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_PERIOD_MONTH'),
887 self::PAYMENT_PERIOD_QUART => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_PERIOD_QUART'),
888 self::PAYMENT_PERIOD_SEMIYEAR => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_PERIOD_SEMIYEAR'),
889 self::PAYMENT_PERIOD_YEAR => Loc::getMessage('PRODUCT_ENTITY_PAYMENT_PERIOD_YEAR'),
890 ];
891 }
892 return [
900 ];
901 }
902
908 public static function getDefaultAvailableSettings()
909 {
910 return [
911 'AVAILABLE' => self::STATUS_NO,
912 'QUANTITY' => 0,
913 'QUANTITY_TRACE' => self::STATUS_YES,
914 'CAN_BUY_ZERO' => self::STATUS_NO,
915 ];
916 }
917
918 public static function getTradingEntityNameByType(int $type): ?string
919 {
920 switch ($type)
921 {
923 case self::TYPE_SET:
924 case self::TYPE_SKU:
925 case self::TYPE_OFFER:
926 $result = Loc::getMessage('PRODUCT_ENTITY_ENTITY_NAME_ANY_PRODUCT');
927 break;
929 $result = Loc::getMessage('PRODUCT_ENTITY_ENTITY_NAME_ANY_SERVICE');
930 break;
933 $result = Loc::getMessage('PRODUCT_ENTITY_ENTITY_NAME_ANY_RESTLESS');
934 break;
935 default:
936 $result = null;
937 }
938
939 return $result;
940 }
941
947 public static function getStoreDocumentRestrictedProductTypes(): array
948 {
949 /*
950 * do not add product type self::TYPE_SKU because the selection for offers is based on head products
951 */
952 return [
956 ];
957 }
958}
static array $defaultProductSettings
Definition product.php:95
static prepareSubscribe($value)
Definition product.php:600
static validatePurchasingCurrency()
Definition product.php:480
static getTradingEntityNameByType(int $type)
Definition product.php:918
static prepareNegativeAmountTrace($value)
Definition product.php:582
static isNeedCheckQuantity(array $fields)
Definition product.php:779
static getPaymentPeriods($descr=false)
Definition product.php:878
static getDefaultAvailableSettings()
Definition product.php:908
static getStoreDocumentRestrictedProductTypes()
Definition product.php:947
static isExistProduct($product)
Definition product.php:620
static getCurrentRatioWithMeasure($product)
Definition product.php:649
static prepareCanBuyZero($value)
Definition product.php:564
static getPaymentTypes($descr=false)
Definition product.php:855
static calculateAvailable($fields)
Definition product.php:737
static loadDefaultProductSettings()
Definition product.php:808
static clearProductCache($product=0)
Definition product.php:640
static getProductTypes($descr=false)
Definition product.php:824
static prepareQuantityTrace($value)
Definition product.php:546
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())