1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
addstorebarcodeaction.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Catalog\Document\Action\Barcode
;
4
5
use
Bitrix\Catalog\Document\Action
;
6
use Bitrix\Catalog\Document\Action\ProductAndStoreInfo;
7
use
Bitrix\Catalog\ProductTable
;
8
use
Bitrix\Main\Application
;
9
use
Bitrix\Main\Error
;
10
use
Bitrix\Main\Localization\Loc
;
11
use
Bitrix\Main\Result
;
12
use CCatalogStoreBarCode;
13
14
Loc::loadMessages(
15
Application::getDocumentRoot() .
'/bitrix/modules/catalog/general/store_docs_type.php'
16
);
17
21
class
AddStoreBarcodeAction
implements
Action
22
{
23
use
ProductAndStoreInfo
;
24
use
BaseStoreBarcodeAction
;
25
29
public
function
canExecute
():
Result
30
{
31
$result
=
new
Result
();
32
33
$row = $this->
getBarcodeRow
();
34
if
($row && $this->productId !== (
int
)$row[
'PRODUCT_ID'
])
35
{
36
$message
= Loc::getMessage(
'CATALOG_STORE_DOCS_ERR_BARCODE_ALREADY_EXIST'
, [
37
'#PRODUCT#'
=> $this->
getProductName
(),
38
'#BARCODE#'
=> $this->barcode,
39
]);
40
$result
->addError(
new
Error
(
$message
));
41
}
42
43
return
$result
;
44
}
45
51
public
function
execute
():
Result
52
{
53
$result
=
new
Result
();
54
55
$row = $this->
getBarcodeRow
();
56
if
($row)
57
{
58
if
($this->storeId === (
int
)$row[
'STORE_ID'
])
59
{
60
// no changes - no action
61
return
$result
;
62
}
63
64
$id = CCatalogStoreBarCode::Update($row[
'ID'
], [
65
'STORE_ID'
=> $this->storeId,
66
'MODIFIED_BY'
=> $this->userId,
67
]);
68
}
69
else
70
{
71
$id = CCatalogStoreBarCode::add([
72
'PRODUCT_ID'
=> $this->productId,
73
'STORE_ID'
=> $this->storeId,
74
'BARCODE'
=> $this->barcode,
75
'MODIFIED_BY'
=> $this->userId,
76
'CREATED_BY'
=> $this->userId,
77
]);
78
}
79
80
if
(!$id)
81
{
82
$result
->addError(
new
Error
(
'Can\'t save barcode'
));
83
}
84
85
return
$result
;
86
}
87
}
Bitrix\Catalog\Document\Action\Barcode\AddStoreBarcodeAction
Определения
addstorebarcodeaction.php:22
Bitrix\Catalog\Document\Action\Barcode\AddStoreBarcodeAction\execute
execute()
Определения
addstorebarcodeaction.php:51
Bitrix\Catalog\Document\Action\Barcode\AddStoreBarcodeAction\canExecute
canExecute()
Определения
addstorebarcodeaction.php:29
Bitrix\Catalog\ProductTable
Определения
product.php:63
Bitrix\Main\Application
Определения
application.php:30
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Localization\Loc
Определения
loc.php:12
Bitrix\Main\ORM\Data\Result
Определения
result.php:16
$result
$result
Определения
get_property_values.php:14
Bitrix\Catalog\Document\Action\ProductAndStoreInfo
trait ProductAndStoreInfo
Определения
productandstoreinfo.php:15
Bitrix\Catalog\Document\Action\Barcode
Определения
addstorebarcodeaction.php:3
Bitrix\Catalog\Document\Action\Barcode\getBarcodeRow
getBarcodeRow()
Определения
basestorebarcodeaction.php:56
Bitrix\Catalog\Document\Action\Barcode\BaseStoreBarcodeAction
trait BaseStoreBarcodeAction
Определения
basestorebarcodeaction.php:11
Bitrix\Catalog\Document\Action
Bitrix\Catalog\Document\Action\getProductName
getProductName()
Определения
productandstoreinfo.php:139
$message
$message
Определения
payment.php:8
bitrix
modules
catalog
lib
document
action
barcode
addstorebarcodeaction.php
Создано системой
1.14.0