Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
MeasureRatioCollection.php
1
<?php
2
3
namespace
Bitrix\Catalog\v2\MeasureRatio
;
4
5
use
Bitrix\Catalog\v2\BaseCollection
;
6
15
class
MeasureRatioCollection
extends
BaseCollection
16
{
18
protected
$factory
;
19
20
public
function
__construct
(
MeasureRatioFactory
$factory
)
21
{
22
$this->factory =
$factory
;
23
}
24
25
public
function
findDefault(): ?
BaseMeasureRatio
26
{
28
foreach
($this->
getIterator
() as $measureRatio)
29
{
30
if
($measureRatio->isDefault())
31
{
32
return
$measureRatio;
33
}
34
}
35
36
return
null
;
37
}
38
39
// ToDo set product id by default? in prices too?
40
public
function
create
():
BaseMeasureRatio
41
{
42
$measureRatio = $this->factory->createEntity();
43
44
$this->
add
($measureRatio);
45
46
return
$measureRatio;
47
}
48
49
public
function
setDefault
(
float
$ratio):
BaseMeasureRatio
50
{
51
$measureRatio = $this->findDefault();
52
53
if
(!$measureRatio)
54
{
55
$measureRatio = $this->
create
()->setDefault();
56
}
57
58
return
$measureRatio->setRatio($ratio);
59
}
60
}
Bitrix\Catalog\v2\BaseCollection
Definition
BaseCollection.php:17
Bitrix\Catalog\v2\BaseCollection\getIterator
getIterator()
Definition
BaseCollection.php:252
Bitrix\Catalog\v2\BaseCollection\add
add(BaseEntity ... $items)
Definition
BaseCollection.php:50
Bitrix\Catalog\v2\MeasureRatio\BaseMeasureRatio
Definition
BaseMeasureRatio.php:17
Bitrix\Catalog\v2\MeasureRatio\MeasureRatioCollection
Definition
MeasureRatioCollection.php:16
Bitrix\Catalog\v2\MeasureRatio\MeasureRatioCollection\$factory
$factory
Definition
MeasureRatioCollection.php:18
Bitrix\Catalog\v2\MeasureRatio\MeasureRatioCollection\create
create()
Definition
MeasureRatioCollection.php:40
Bitrix\Catalog\v2\MeasureRatio\MeasureRatioCollection\__construct
__construct(MeasureRatioFactory $factory)
Definition
MeasureRatioCollection.php:20
Bitrix\Catalog\v2\MeasureRatio\MeasureRatioCollection\setDefault
setDefault(float $ratio)
Definition
MeasureRatioCollection.php:49
Bitrix\Catalog\v2\MeasureRatio\MeasureRatioFactory
Definition
MeasureRatioFactory.php:16
Bitrix\Catalog\v2\MeasureRatio
Definition
BaseMeasureRatio.php:3
modules
catalog
lib
v2
MeasureRatio
MeasureRatioCollection.php
Создано системой
1.10.0