1
|
|
|
<?php namespace Zenwalker\CommerceML\Model; |
2
|
|
|
|
3
|
|
|
use Zenwalker\CommerceML\Collections\ImageCollection; |
4
|
|
|
use Zenwalker\CommerceML\Collections\PropertyCollection; |
5
|
|
|
use Zenwalker\CommerceML\Collections\RequisiteCollection; |
6
|
|
|
use Zenwalker\CommerceML\Collections\SpecificationCollection; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class Product |
10
|
|
|
* |
11
|
|
|
* @package Zenwalker\CommerceML\Model |
12
|
|
|
* @property string !Штрихкод |
13
|
|
|
* @property string !Артикул |
14
|
|
|
* @property string !Наименование |
15
|
|
|
* |
16
|
|
|
* @property \SimpleXMLElement !БазоваяЕдиница |
17
|
|
|
* @property ImageCollection images |
18
|
|
|
* @property Offer offer |
19
|
|
|
* @property Offer[] offers |
20
|
|
|
* @property Group group |
21
|
|
|
* @property RequisiteCollection requisites |
22
|
|
|
* @property Price[] prices |
23
|
|
|
* @property PropertyCollection properties |
24
|
|
|
*/ |
25
|
|
|
class Product extends Simple |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var PropertyCollection Свойства продукта |
29
|
|
|
*/ |
30
|
|
|
protected $properties; |
31
|
|
|
/** |
32
|
|
|
* @var RequisiteCollection |
33
|
|
|
*/ |
34
|
|
|
protected $requisites; |
35
|
|
|
/** |
36
|
|
|
* @var SpecificationCollection |
37
|
|
|
*/ |
38
|
|
|
protected $specifications; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var Price |
42
|
|
|
*/ |
43
|
|
|
protected $prices; |
44
|
|
|
/** |
45
|
|
|
* @var Group |
46
|
|
|
*/ |
47
|
|
|
protected $group; |
48
|
|
|
|
49
|
|
|
protected $images; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return PropertyCollection<Simple> |
53
|
|
|
*/ |
54
|
|
|
public function getProperties() |
55
|
|
|
{ |
56
|
|
|
if (!$this->properties) { |
57
|
|
|
$this->properties = new PropertyCollection($this->owner, $this->xml->ЗначенияСвойств); |
58
|
|
|
} |
59
|
|
|
return $this->properties; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return SpecificationCollection |
64
|
|
|
* @deprecated will removed in 0.3.0 |
65
|
|
|
*/ |
66
|
|
|
public function getSpecifications() |
67
|
|
|
{ |
68
|
|
|
return $this->getOffer() ? $this->getOffer()->getSpecifications() : null; |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return Price[] |
73
|
|
|
* @deprecated will removed in 0.3.0 |
74
|
|
|
*/ |
75
|
|
|
public function getPrices() |
76
|
|
|
{ |
77
|
|
|
return $this->getOffer() ? $this->getOffer()->getPrices() : []; |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return RequisiteCollection |
82
|
|
|
*/ |
83
|
1 |
|
public function getRequisites() |
84
|
|
|
{ |
85
|
1 |
|
if (!$this->requisites) { |
86
|
1 |
|
$this->requisites = new RequisiteCollection($this->owner, $this->xml->ЗначенияРеквизитов); |
87
|
|
|
} |
88
|
1 |
|
return $this->requisites; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return Group |
93
|
|
|
*/ |
94
|
|
|
public function getGroup() |
95
|
|
|
{ |
96
|
|
|
if (!$this->group) { |
97
|
|
|
foreach ($this->owner->classifier->getGroups() as $group) { |
98
|
|
|
if ($group->id === $this->Группы->Ид) { |
|
|
|
|
99
|
|
|
$this->group = $group; |
100
|
|
|
} elseif ($child = $group->getChildById($this->Группы->Ид)) { |
101
|
|
|
$this->group = $child; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
return $this->group; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return null|Offer |
110
|
|
|
* @deprecated will removed in 0.3.0 |
111
|
|
|
*/ |
112
|
|
|
public function getOffer() |
113
|
|
|
{ |
114
|
|
|
return $this->owner->offerPackage->getOfferById($this->getClearId()); |
|
|
|
|
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return Offer[] |
119
|
|
|
*/ |
120
|
1 |
|
public function getOffers() |
121
|
|
|
{ |
122
|
1 |
|
return $this->owner->offerPackage->getOffersById($this->getClearId()); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return ImageCollection |
127
|
|
|
*/ |
128
|
1 |
|
public function getImages() |
129
|
|
|
{ |
130
|
1 |
|
if (!$this->images) { |
131
|
1 |
|
$this->images = new ImageCollection($this->owner, $this->xml->Картинка); |
132
|
|
|
} |
133
|
1 |
|
return $this->images; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.