Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
IblockInfo.php
1
<?php
2
3
namespace
Bitrix\Catalog\v2\Iblock
;
4
5
use
Bitrix\Main\ObjectNotFoundException
;
6
use
Bitrix\Main\Type\Dictionary
;
7
16
class
IblockInfo
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
}
Bitrix\Catalog\v2\Iblock\IblockInfo
Definition
IblockInfo.php:17
Bitrix\Catalog\v2\Iblock\IblockInfo\canHaveSku
canHaveSku()
Definition
IblockInfo.php:56
Bitrix\Catalog\v2\Iblock\IblockInfo\getCatalogType
getCatalogType()
Definition
IblockInfo.php:37
Bitrix\Catalog\v2\Iblock\IblockInfo\getSkuIblockId
getSkuIblockId()
Definition
IblockInfo.php:65
Bitrix\Catalog\v2\Iblock\IblockInfo\toArray
toArray()
Definition
IblockInfo.php:32
Bitrix\Catalog\v2\Iblock\IblockInfo\__construct
__construct(int $iblockId)
Definition
IblockInfo.php:20
Bitrix\Catalog\v2\Iblock\IblockInfo\getProductIblockId
getProductIblockId()
Definition
IblockInfo.php:43
Bitrix\Catalog\v2\Iblock\IblockInfo\getSkuPropertyId
getSkuPropertyId()
Definition
IblockInfo.php:70
Bitrix\Catalog\v2\Iblock\IblockInfo\hasSubscription
hasSubscription()
Definition
IblockInfo.php:51
Bitrix\Catalog\v2\Iblock\IblockInfo\getVatId
getVatId()
Definition
IblockInfo.php:75
Bitrix\Main\ObjectNotFoundException
Definition
exception.php:203
Bitrix\Main\Type\Dictionary
Definition
dictionary.php:6
Bitrix\Catalog\v2\Iblock
Definition
IblockInfo.php:3
modules
catalog
lib
v2
Iblock
IblockInfo.php
Создано системой
1.10.0