commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
VariantDraftModel.php
1<?php
2
3declare(strict_types=1);
10
20use stdClass;
21
25final class VariantDraftModel extends JsonObjectModel implements VariantDraft
26{
31 protected $key;
32
37 protected $sku;
38
43 protected $product;
44
49 protected $publish;
50
55 protected $images;
56
61 protected $attributes;
62
67 protected $assets;
68
69
73 public function __construct(
74 ?string $key = null,
75 ?string $sku = null,
77 ?bool $publish = null,
81 ) {
82 $this->key = $key;
83 $this->sku = $sku;
84 $this->product = $product;
85 $this->publish = $publish;
86 $this->images = $images;
87 $this->attributes = $attributes;
88 $this->assets = $assets;
89 }
90
98 public function getKey()
99 {
100 if (is_null($this->key)) {
102 $data = $this->raw(self::FIELD_KEY);
103 if (is_null($data)) {
104 return null;
105 }
106 $this->key = (string) $data;
107 }
108
109 return $this->key;
110 }
111
118 public function getSku()
119 {
120 if (is_null($this->sku)) {
122 $data = $this->raw(self::FIELD_SKU);
123 if (is_null($data)) {
124 return null;
125 }
126 $this->sku = (string) $data;
127 }
128
129 return $this->sku;
130 }
131
138 public function getProduct()
139 {
140 if (is_null($this->product)) {
142 $data = $this->raw(self::FIELD_PRODUCT);
143 if (is_null($data)) {
144 return null;
145 }
146
147 $this->product = ProductResourceIdentifierModel::of($data);
148 }
149
150 return $this->product;
151 }
152
160 public function getPublish()
161 {
162 if (is_null($this->publish)) {
164 $data = $this->raw(self::FIELD_PUBLISH);
165 if (is_null($data)) {
166 return null;
167 }
168 $this->publish = (bool) $data;
169 }
170
171 return $this->publish;
172 }
173
180 public function getImages()
181 {
182 if (is_null($this->images)) {
184 $data = $this->raw(self::FIELD_IMAGES);
185 if (is_null($data)) {
186 return null;
187 }
188 $this->images = ImageCollection::fromArray($data);
189 }
190
191 return $this->images;
192 }
193
200 public function getAttributes()
201 {
202 if (is_null($this->attributes)) {
204 $data = $this->raw(self::FIELD_ATTRIBUTES);
205 if (is_null($data)) {
206 return null;
207 }
208 $this->attributes = AttributeCollection::fromArray($data);
209 }
210
211 return $this->attributes;
212 }
213
220 public function getAssets()
221 {
222 if (is_null($this->assets)) {
224 $data = $this->raw(self::FIELD_ASSETS);
225 if (is_null($data)) {
226 return null;
227 }
228 $this->assets = AssetDraftCollection::fromArray($data);
229 }
230
231 return $this->assets;
232 }
233
234
238 public function setKey(?string $key): void
239 {
240 $this->key = $key;
241 }
242
246 public function setSku(?string $sku): void
247 {
248 $this->sku = $sku;
249 }
250
255 {
256 $this->product = $product;
257 }
258
262 public function setPublish(?bool $publish): void
263 {
264 $this->publish = $publish;
265 }
266
270 public function setImages(?ImageCollection $images): void
271 {
272 $this->images = $images;
273 }
274
279 {
280 $this->attributes = $attributes;
281 }
282
286 public function setAssets(?AssetDraftCollection $assets): void
287 {
288 $this->assets = $assets;
289 }
290}
__construct(?string $key=null, ?string $sku=null, ?ProductResourceIdentifier $product=null, ?bool $publish=null, ?ImageCollection $images=null, ?AttributeCollection $attributes=null, ?AssetDraftCollection $assets=null)
setProduct(?ProductResourceIdentifier $product)