commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductVariantModel.php
1<?php
2
3declare(strict_types=1);
10
22use stdClass;
23
28{
33 protected $id;
34
39 protected $sku;
40
45 protected $key;
46
51 protected $prices;
52
57 protected $attributes;
58
63 protected $price;
64
69 protected $images;
70
75 protected $assets;
76
81 protected $availability;
82
88
93 protected $scopedPrice;
94
100
106
107
111 public function __construct(
112 ?int $id = null,
113 ?string $sku = null,
114 ?string $key = null,
115 ?PriceCollection $prices = null,
117 ?Price $price = null,
118 ?ImageCollection $images = null,
119 ?AssetCollection $assets = null,
121 ?bool $isMatchingVariant = null,
123 ?bool $scopedPriceDiscounted = null,
125 ) {
126 $this->id = $id;
127 $this->sku = $sku;
128 $this->key = $key;
129 $this->prices = $prices;
130 $this->attributes = $attributes;
131 $this->price = $price;
132 $this->images = $images;
133 $this->assets = $assets;
134 $this->availability = $availability;
135 $this->isMatchingVariant = $isMatchingVariant;
136 $this->scopedPrice = $scopedPrice;
137 $this->scopedPriceDiscounted = $scopedPriceDiscounted;
138 $this->recurrencePrices = $recurrencePrices;
139 }
140
147 public function getId()
148 {
149 if (is_null($this->id)) {
151 $data = $this->raw(self::FIELD_ID);
152 if (is_null($data)) {
153 return null;
154 }
155 $this->id = (int) $data;
156 }
157
158 return $this->id;
159 }
160
167 public function getSku()
168 {
169 if (is_null($this->sku)) {
171 $data = $this->raw(self::FIELD_SKU);
172 if (is_null($data)) {
173 return null;
174 }
175 $this->sku = (string) $data;
176 }
177
178 return $this->sku;
179 }
180
188 public function getKey()
189 {
190 if (is_null($this->key)) {
192 $data = $this->raw(self::FIELD_KEY);
193 if (is_null($data)) {
194 return null;
195 }
196 $this->key = (string) $data;
197 }
198
199 return $this->key;
200 }
201
209 public function getPrices()
210 {
211 if (is_null($this->prices)) {
213 $data = $this->raw(self::FIELD_PRICES);
214 if (is_null($data)) {
215 return null;
216 }
217 $this->prices = PriceCollection::fromArray($data);
218 }
219
220 return $this->prices;
221 }
222
229 public function getAttributes()
230 {
231 if (is_null($this->attributes)) {
233 $data = $this->raw(self::FIELD_ATTRIBUTES);
234 if (is_null($data)) {
235 return null;
236 }
237 $this->attributes = AttributeCollection::fromArray($data);
238 }
239
240 return $this->attributes;
241 }
242
250 public function getPrice()
251 {
252 if (is_null($this->price)) {
254 $data = $this->raw(self::FIELD_PRICE);
255 if (is_null($data)) {
256 return null;
257 }
258
259 $this->price = PriceModel::of($data);
260 }
261
262 return $this->price;
263 }
264
271 public function getImages()
272 {
273 if (is_null($this->images)) {
275 $data = $this->raw(self::FIELD_IMAGES);
276 if (is_null($data)) {
277 return null;
278 }
279 $this->images = ImageCollection::fromArray($data);
280 }
281
282 return $this->images;
283 }
284
291 public function getAssets()
292 {
293 if (is_null($this->assets)) {
295 $data = $this->raw(self::FIELD_ASSETS);
296 if (is_null($data)) {
297 return null;
298 }
299 $this->assets = AssetCollection::fromArray($data);
300 }
301
302 return $this->assets;
303 }
304
313 public function getAvailability()
314 {
315 if (is_null($this->availability)) {
317 $data = $this->raw(self::FIELD_AVAILABILITY);
318 if (is_null($data)) {
319 return null;
320 }
321
322 $this->availability = ProductVariantAvailabilityModel::of($data);
323 }
324
325 return $this->availability;
326 }
327
335 public function getIsMatchingVariant()
336 {
337 if (is_null($this->isMatchingVariant)) {
339 $data = $this->raw(self::FIELD_IS_MATCHING_VARIANT);
340 if (is_null($data)) {
341 return null;
342 }
343 $this->isMatchingVariant = (bool) $data;
344 }
345
347 }
348
357 public function getScopedPrice()
358 {
359 if (is_null($this->scopedPrice)) {
361 $data = $this->raw(self::FIELD_SCOPED_PRICE);
362 if (is_null($data)) {
363 return null;
364 }
365
366 $this->scopedPrice = ScopedPriceModel::of($data);
367 }
368
369 return $this->scopedPrice;
370 }
371
379 public function getScopedPriceDiscounted()
380 {
381 if (is_null($this->scopedPriceDiscounted)) {
383 $data = $this->raw(self::FIELD_SCOPED_PRICE_DISCOUNTED);
384 if (is_null($data)) {
385 return null;
386 }
387 $this->scopedPriceDiscounted = (bool) $data;
388 }
389
391 }
392
400 public function getRecurrencePrices()
401 {
402 if (is_null($this->recurrencePrices)) {
404 $data = $this->raw(self::FIELD_RECURRENCE_PRICES);
405 if (is_null($data)) {
406 return null;
407 }
408 $this->recurrencePrices = PriceCollection::fromArray($data);
409 }
410
412 }
413
414
418 public function setId(?int $id): void
419 {
420 $this->id = $id;
421 }
422
426 public function setSku(?string $sku): void
427 {
428 $this->sku = $sku;
429 }
430
434 public function setKey(?string $key): void
435 {
436 $this->key = $key;
437 }
438
442 public function setPrices(?PriceCollection $prices): void
443 {
444 $this->prices = $prices;
445 }
446
451 {
452 $this->attributes = $attributes;
453 }
454
458 public function setPrice(?Price $price): void
459 {
460 $this->price = $price;
461 }
462
466 public function setImages(?ImageCollection $images): void
467 {
468 $this->images = $images;
469 }
470
474 public function setAssets(?AssetCollection $assets): void
475 {
476 $this->assets = $assets;
477 }
478
483 {
484 $this->availability = $availability;
485 }
486
490 public function setIsMatchingVariant(?bool $isMatchingVariant): void
491 {
492 $this->isMatchingVariant = $isMatchingVariant;
493 }
494
499 {
500 $this->scopedPrice = $scopedPrice;
501 }
502
507 {
508 $this->scopedPriceDiscounted = $scopedPriceDiscounted;
509 }
510
515 {
516 $this->recurrencePrices = $recurrencePrices;
517 }
518}
__construct(?int $id=null, ?string $sku=null, ?string $key=null, ?PriceCollection $prices=null, ?AttributeCollection $attributes=null, ?Price $price=null, ?ImageCollection $images=null, ?AssetCollection $assets=null, ?ProductVariantAvailability $availability=null, ?bool $isMatchingVariant=null, ?ScopedPrice $scopedPrice=null, ?bool $scopedPriceDiscounted=null, ?PriceCollection $recurrencePrices=null)
setAvailability(?ProductVariantAvailability $availability)
setRecurrencePrices(?PriceCollection $recurrencePrices)
static fromArray(array $data)