Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
StoreProduct.php
1<?php
2
4
7use Bitrix\Catalog\v2\HasSettingsTrait;
8
19{
21
22 public function __construct(StoreProductRepositoryContract $repository)
23 {
24 parent::__construct($repository);
25 }
26
27 public function setStoreId(int $storeId): self
28 {
29 $this->setField('STORE_ID', $storeId);
30
31 return $this;
32 }
33
34 public function getStoreId(): string
35 {
36 return $this->getField('STORE_ID');
37 }
38
39 public function setProductId(int $productId): self
40 {
41 $this->setField('PRODUCT_ID', $productId);
42
43 return $this;
44 }
45
46 public function getProductId(): int
47 {
48 return (int)$this->getField('PRODUCT_ID');
49 }
50
51 public function setAmount(?float $amount): self
52 {
53 $this->setField('AMOUNT', $amount);
54
55 return $this;
56 }
57
58 public function unsetAmount(): self
59 {
60 return $this->setAmount(null);
61 }
62
63 public function hasAmount(): bool
64 {
65 return $this->hasField('AMOUNT');
66 }
67
68 public function getAmount(): ?float
69 {
70 return $this->hasAmount() ? (float)$this->getField('AMOUNT') : null;
71 }
72
73 protected function getFieldsMap(): array
74 {
75 return [
76 'ID' => MapTypeCaster::NULLABLE_INT,
77 'STORE_ID' => MapTypeCaster::INT,
78 'PRODUCT_ID' => MapTypeCaster::INT,
79 'AMOUNT' => MapTypeCaster::NULLABLE_FLOAT,
80 'QUANTITY_RESERVED' => MapTypeCaster::NULLABLE_FLOAT,
81 ];
82 }
83}
setField(string $name, $value)
__construct(StoreProductRepositoryContract $repository)