Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
writeoffamountvalidator.php
1
<?php
2
3
namespace
Bitrix\Catalog\Document\Action\Store
;
4
5
use Bitrix\Catalog\Document\Action\ProductAndStoreInfo;
6
use Bitrix\Catalog\EO_StoreDocumentElement;
7
use
Bitrix\Main\Error
;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Main\Result
;
10
14
trait
WriteOffAmountValidator
15
{
16
use ProductAndStoreInfo;
17
18
protected
function
checkStoreAmount
(EO_StoreDocumentElement $storeDocumentElement =
null
):
Result
19
{
20
$result =
new
Result
();
21
22
if
(empty($storeDocumentElement))
23
{
24
$result->addError(
new
Error
(
Loc::getMessage
(
"CATALOG_STORE_EMPTY_DOC_ELEMENT"
)));
25
26
return
$result;
27
}
28
29
if
($this->
getStoreProductAmount
() - $storeDocumentElement->getAmount() < 0)
30
{
31
$message =
Loc::getMessage
(
32
"CATALOG_STORE_DOCS_ERR_INSUFFICIENTLY_AMOUNT_EXT"
,
33
[
34
"#STORE#"
=> $this->
getStoreName
(),
35
"#PRODUCT#"
=> $this->
getProductName
(),
36
]
37
);
38
39
$result->addError(
new
Error
($message));
40
}
41
42
return
$result;
43
}
44
}
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Catalog\Document\Action\Store
Definition
basestorequantityaction.php:3
Bitrix\Catalog\Document\Action\Store\WriteOffAmountValidator
trait WriteOffAmountValidator
Definition
writeoffamountvalidator.php:15
Bitrix\Catalog\Document\Action\Store\checkStoreAmount
checkStoreAmount(EO_StoreDocumentElement $storeDocumentElement=null)
Definition
writeoffamountvalidator.php:18
Bitrix\Catalog\Document\Action\getStoreProductAmount
getStoreProductAmount()
Definition
productandstoreinfo.php:119
Bitrix\Catalog\Document\Action\getProductName
getProductName()
Definition
productandstoreinfo.php:139
Bitrix\Catalog\Document\Action\getStoreName
getStoreName()
Definition
productandstoreinfo.php:51
modules
catalog
lib
document
action
store
writeoffamountvalidator.php
Создано системой
1.10.0