Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
basereservestoreproductaction.php
1
<?php
2
3
namespace
Bitrix\Catalog\Document\Action\Reserve
;
4
5
use Bitrix\Catalog\Document\Action\ProductAndStoreInfo;
6
use
Bitrix\Main\Application
;
7
use
Bitrix\Main\Error
;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Main\Result
;
10
use CCatalogProduct;
11
use CCatalogStoreProduct;
12
13
Loc::loadMessages
(
14
Application::getDocumentRoot
() .
'/bitrix/modules/catalog/general/store_docs_type.php'
15
);
16
20
trait
BaseReserveStoreProductAction
21
{
22
use ProductAndStoreInfo;
23
27
protected
$storeId
;
28
32
protected
$productId
;
33
37
protected
$amount
;
38
44
public
function
__construct
(
int
$storeId
,
int
$productId
,
float
$amount
)
45
{
46
$this->storeId =
$storeId
;
47
$this->productId =
$productId
;
48
$this->amount =
$amount
;
49
}
50
56
abstract
protected
function
getNewProductQuantity
(): float;
57
63
abstract
protected
function
getNewProductReservedQuantity
(): float;
64
70
abstract
protected
function
getNewStoreReservedQuantity
(): float;
71
75
public
function
execute
():
Result
76
{
77
$result =
new
Result
();
78
79
// update store info
80
$ret = CCatalogStoreProduct::UpdateFromForm([
81
'PRODUCT_ID'
=> $this->productId,
82
'STORE_ID'
=> $this->storeId,
83
'AMOUNT'
=> $this->
getStoreProductAmount
(),
84
'QUANTITY_RESERVED'
=> $this->
getNewStoreReservedQuantity
(),
85
]);
86
if
(!$ret)
87
{
88
$result->addError(
89
new
Error
(
Loc::getMessage
(
"CATALOG_STORE_DOCS_ERR_CANT_UPDATE_STORE_PRODUCT"
))
90
);
91
return
$result;
92
}
93
94
// update product info
95
$ret = CCatalogProduct::Update($this->productId, [
96
'QUANTITY'
=> $this->
getNewProductQuantity
(),
97
'QUANTITY_RESERVED'
=> $this->
getNewProductReservedQuantity
(),
98
]);
99
if
(!$ret)
100
{
101
$result->addError(
102
new
Error
(
Loc::getMessage
(
"CATALOG_STORE_DOCS_ERR_PURCHASING_INFO_ERROR"
))
103
);
104
return
$result;
105
}
106
107
return
$result;
108
}
109
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getDocumentRoot
static getDocumentRoot()
Definition
application.php:717
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
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\Reserve
Definition
basereservestoreproductaction.php:3
Bitrix\Catalog\Document\Action\Reserve\execute
execute()
Definition
basereservestoreproductaction.php:75
Bitrix\Catalog\Document\Action\Reserve\getNewProductReservedQuantity
getNewProductReservedQuantity()
Bitrix\Catalog\Document\Action\Reserve\getNewProductQuantity
getNewProductQuantity()
Bitrix\Catalog\Document\Action\Reserve\getNewStoreReservedQuantity
getNewStoreReservedQuantity()
Bitrix\Catalog\Document\Action\Reserve\BaseReserveStoreProductAction
trait BaseReserveStoreProductAction
Definition
basereservestoreproductaction.php:21
Bitrix\Catalog\Document\Action\Reserve\__construct
__construct(int $storeId, int $productId, float $amount)
Definition
basereservestoreproductaction.php:44
Bitrix\Catalog\Document\Action\Reserve\$productId
$productId
Definition
basereservestoreproductaction.php:32
Bitrix\Catalog\Document\Action\Reserve\$amount
$amount
Definition
basereservestoreproductaction.php:37
Bitrix\Catalog\Document\Action\Reserve\$storeId
$storeId
Definition
basereservestoreproductaction.php:27
Bitrix\Catalog\Document\Action\getStoreProductAmount
getStoreProductAmount()
Definition
productandstoreinfo.php:119
modules
catalog
lib
document
action
reserve
basereservestoreproductaction.php
Создано системой
1.10.0