commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductVariantBuilder.php
1<?php
2
3declare(strict_types=1);
10
23use stdClass;
24
28final class ProductVariantBuilder implements Builder
29{
34 private $id;
35
40 private $sku;
41
46 private $key;
47
52 private $prices;
53
58 private $attributes;
59
64 private $price;
65
70 private $images;
71
76 private $assets;
77
82 private $availability;
83
88 private $isMatchingVariant;
89
94 private $scopedPrice;
95
100 private $scopedPriceDiscounted;
101
106 private $recurrencePrices;
107
114 public function getId()
115 {
116 return $this->id;
117 }
118
125 public function getSku()
126 {
127 return $this->sku;
128 }
129
137 public function getKey()
138 {
139 return $this->key;
140 }
141
149 public function getPrices()
150 {
151 return $this->prices;
152 }
153
160 public function getAttributes()
161 {
162 return $this->attributes;
163 }
164
172 public function getPrice()
173 {
174 return $this->price instanceof PriceBuilder ? $this->price->build() : $this->price;
175 }
176
183 public function getImages()
184 {
185 return $this->images;
186 }
187
194 public function getAssets()
195 {
196 return $this->assets;
197 }
198
207 public function getAvailability()
208 {
209 return $this->availability instanceof ProductVariantAvailabilityBuilder ? $this->availability->build() : $this->availability;
210 }
211
219 public function getIsMatchingVariant()
220 {
221 return $this->isMatchingVariant;
222 }
223
232 public function getScopedPrice()
233 {
234 return $this->scopedPrice instanceof ScopedPriceBuilder ? $this->scopedPrice->build() : $this->scopedPrice;
235 }
236
244 public function getScopedPriceDiscounted()
245 {
246 return $this->scopedPriceDiscounted;
247 }
248
256 public function getRecurrencePrices()
257 {
258 return $this->recurrencePrices;
259 }
260
265 public function withId(?int $id)
266 {
267 $this->id = $id;
268
269 return $this;
270 }
271
276 public function withSku(?string $sku)
277 {
278 $this->sku = $sku;
279
280 return $this;
281 }
282
287 public function withKey(?string $key)
288 {
289 $this->key = $key;
290
291 return $this;
292 }
293
298 public function withPrices(?PriceCollection $prices)
299 {
300 $this->prices = $prices;
301
302 return $this;
303 }
304
309 public function withAttributes(?AttributeCollection $attributes)
310 {
311 $this->attributes = $attributes;
312
313 return $this;
314 }
315
320 public function withPrice(?Price $price)
321 {
322 $this->price = $price;
323
324 return $this;
325 }
326
331 public function withImages(?ImageCollection $images)
332 {
333 $this->images = $images;
334
335 return $this;
336 }
337
342 public function withAssets(?AssetCollection $assets)
343 {
344 $this->assets = $assets;
345
346 return $this;
347 }
348
353 public function withAvailability(?ProductVariantAvailability $availability)
354 {
355 $this->availability = $availability;
356
357 return $this;
358 }
359
364 public function withIsMatchingVariant(?bool $isMatchingVariant)
365 {
366 $this->isMatchingVariant = $isMatchingVariant;
367
368 return $this;
369 }
370
375 public function withScopedPrice(?ScopedPrice $scopedPrice)
376 {
377 $this->scopedPrice = $scopedPrice;
378
379 return $this;
380 }
381
386 public function withScopedPriceDiscounted(?bool $scopedPriceDiscounted)
387 {
388 $this->scopedPriceDiscounted = $scopedPriceDiscounted;
389
390 return $this;
391 }
392
397 public function withRecurrencePrices(?PriceCollection $recurrencePrices)
398 {
399 $this->recurrencePrices = $recurrencePrices;
400
401 return $this;
402 }
403
408 public function withPriceBuilder(?PriceBuilder $price)
409 {
410 $this->price = $price;
411
412 return $this;
413 }
414
420 {
421 $this->availability = $availability;
422
423 return $this;
424 }
425
430 public function withScopedPriceBuilder(?ScopedPriceBuilder $scopedPrice)
431 {
432 $this->scopedPrice = $scopedPrice;
433
434 return $this;
435 }
436
437 public function build(): ProductVariant
438 {
439 return new ProductVariantModel(
440 $this->id,
441 $this->sku,
442 $this->key,
443 $this->prices,
444 $this->attributes,
445 $this->price instanceof PriceBuilder ? $this->price->build() : $this->price,
446 $this->images,
447 $this->assets,
448 $this->availability instanceof ProductVariantAvailabilityBuilder ? $this->availability->build() : $this->availability,
449 $this->isMatchingVariant,
450 $this->scopedPrice instanceof ScopedPriceBuilder ? $this->scopedPrice->build() : $this->scopedPrice,
451 $this->scopedPriceDiscounted,
452 $this->recurrencePrices
453 );
454 }
455
456 public static function of(): ProductVariantBuilder
457 {
458 return new self();
459 }
460}
withAvailabilityBuilder(?ProductVariantAvailabilityBuilder $availability)
withAvailability(?ProductVariantAvailability $availability)