Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
IblockInfo.php
1<?php
2
4
7
17{
18 private $iblock;
19
20 public function __construct(int $iblockId)
21 {
22 $iblockInfo = \CCatalogSku::GetInfoByIBlock($iblockId);
23
24 if (!$iblockInfo || !is_array($iblockInfo))
25 {
26 throw new ObjectNotFoundException("Can not find catalog iblock {{$iblockId}}.");
27 }
28
29 $this->iblock = new Dictionary($iblockInfo);
30 }
31
32 public function toArray(): array
33 {
34 return $this->iblock->toArray();
35 }
36
37 public function getCatalogType()
38 {
39 return $this->iblock->get('CATALOG_TYPE');
40 }
41
42 // ToDo all these wrappers
43 public function getProductIblockId(): int
44 {
45 return
46 $this->canHaveSku()
47 ? (int)$this->iblock->get('PRODUCT_IBLOCK_ID')
48 : (int)$this->iblock->get('IBLOCK_ID');
49 }
50
51 public function hasSubscription(): bool
52 {
53 return $this->iblock->get('SUBSCRIPTION') === 'Y';
54 }
55
56 public function canHaveSku(): bool
57 {
58 return (
59 $this->getCatalogType() === \CCatalogSku::TYPE_OFFERS
60 || $this->getCatalogType() === \CCatalogSku::TYPE_FULL
61 || $this->getCatalogType() === \CCatalogSku::TYPE_PRODUCT
62 );
63 }
64
65 public function getSkuIblockId(): ?int
66 {
67 return $this->canHaveSku() ? (int)$this->iblock->get('IBLOCK_ID') : null;
68 }
69
70 public function getSkuPropertyId(): ?int
71 {
72 return $this->canHaveSku() ? (int)$this->iblock->get('SKU_PROPERTY_ID') : null;
73 }
74
75 public function getVatId(): ?int
76 {
77 return (int)$this->iblock->get('VAT_ID') ?: null;
78 }
79}