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 \SimpleXMLElement Штрихкод |
13
|
|
|
* @property \SimpleXMLElement Артикул |
14
|
|
|
* @property \SimpleXMLElement Наименование |
15
|
|
|
* @property \SimpleXMLElement БазоваяЕдиница |
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<Property> |
53
|
|
|
*/ |
54
|
2 |
|
public function getProperties() |
55
|
|
|
{ |
56
|
2 |
|
if (!$this->properties) { |
57
|
2 |
|
$this->properties = new PropertyCollection($this->owner, $this->xml->ЗначенияСвойств); |
|
|
|
|
58
|
|
|
} |
59
|
2 |
|
return $this->properties; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return SpecificationCollection|null|array |
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
|
1 |
|
public function getGroup() |
95
|
|
|
{ |
96
|
1 |
|
if (!$this->group) { |
97
|
1 |
|
if (!$this->Группы) { |
98
|
|
|
return null; |
99
|
|
|
} |
100
|
1 |
|
$groupId = (string)$this->Группы->Ид; |
101
|
1 |
|
$this->group = $this->owner->classifier->getGroupById($groupId); |
102
|
|
|
} |
103
|
1 |
|
return $this->group; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return null|Offer |
108
|
|
|
* @deprecated will removed in 0.3.0 |
109
|
|
|
*/ |
110
|
|
|
public function getOffer() |
111
|
|
|
{ |
112
|
|
|
return $this->owner->offerPackage->getOfferById($this->getClearId()); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return Offer[] |
117
|
|
|
*/ |
118
|
6 |
|
public function getOffers() |
119
|
|
|
{ |
120
|
6 |
|
return $this->owner->offerPackage->getOffersById($this->getClearId()); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return ImageCollection |
125
|
|
|
*/ |
126
|
1 |
|
public function getImages() |
127
|
|
|
{ |
128
|
1 |
|
if (!$this->images) { |
129
|
1 |
|
$this->images = new ImageCollection($this->owner, $this->xml->Картинка); |
130
|
|
|
} |
131
|
1 |
|
return $this->images; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|