commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductDraftModel.php
1<?php
2
3declare(strict_types=1);
10
24use stdClass;
25
29final class ProductDraftModel extends JsonObjectModel implements ProductDraft
30{
35 protected $productType;
36
41 protected $name;
42
47 protected $slug;
48
53 protected $key;
54
59 protected $description;
60
65 protected $categories;
66
72
77 protected $metaTitle;
78
84
89 protected $metaKeywords;
90
95 protected $masterVariant;
96
101 protected $variants;
102
107 protected $taxCategory;
108
114
119 protected $state;
120
125 protected $publish;
126
131 protected $priceMode;
132
137 protected $attributes;
138
139
143 public function __construct(
145 ?LocalizedString $name = null,
146 ?LocalizedString $slug = null,
147 ?string $key = null,
159 ?bool $publish = null,
160 ?string $priceMode = null,
162 ) {
163 $this->productType = $productType;
164 $this->name = $name;
165 $this->slug = $slug;
166 $this->key = $key;
167 $this->description = $description;
168 $this->categories = $categories;
169 $this->categoryOrderHints = $categoryOrderHints;
170 $this->metaTitle = $metaTitle;
171 $this->metaDescription = $metaDescription;
172 $this->metaKeywords = $metaKeywords;
173 $this->masterVariant = $masterVariant;
174 $this->variants = $variants;
175 $this->taxCategory = $taxCategory;
176 $this->searchKeywords = $searchKeywords;
177 $this->state = $state;
178 $this->publish = $publish;
179 $this->priceMode = $priceMode;
180 $this->attributes = $attributes;
181 }
182
189 public function getProductType()
190 {
191 if (is_null($this->productType)) {
193 $data = $this->raw(self::FIELD_PRODUCT_TYPE);
194 if (is_null($data)) {
195 return null;
196 }
197
198 $this->productType = ProductTypeResourceIdentifierModel::of($data);
199 }
200
201 return $this->productType;
202 }
203
210 public function getName()
211 {
212 if (is_null($this->name)) {
214 $data = $this->raw(self::FIELD_NAME);
215 if (is_null($data)) {
216 return null;
217 }
218
219 $this->name = LocalizedStringModel::of($data);
220 }
221
222 return $this->name;
223 }
224
233 public function getSlug()
234 {
235 if (is_null($this->slug)) {
237 $data = $this->raw(self::FIELD_SLUG);
238 if (is_null($data)) {
239 return null;
240 }
241
242 $this->slug = LocalizedStringModel::of($data);
243 }
244
245 return $this->slug;
246 }
247
256 public function getKey()
257 {
258 if (is_null($this->key)) {
260 $data = $this->raw(self::FIELD_KEY);
261 if (is_null($data)) {
262 return null;
263 }
264 $this->key = (string) $data;
265 }
266
267 return $this->key;
268 }
269
276 public function getDescription()
277 {
278 if (is_null($this->description)) {
280 $data = $this->raw(self::FIELD_DESCRIPTION);
281 if (is_null($data)) {
282 return null;
283 }
284
285 $this->description = LocalizedStringModel::of($data);
286 }
287
288 return $this->description;
289 }
290
297 public function getCategories()
298 {
299 if (is_null($this->categories)) {
301 $data = $this->raw(self::FIELD_CATEGORIES);
302 if (is_null($data)) {
303 return null;
304 }
305 $this->categories = CategoryResourceIdentifierCollection::fromArray($data);
306 }
307
308 return $this->categories;
309 }
310
317 public function getCategoryOrderHints()
318 {
319 if (is_null($this->categoryOrderHints)) {
321 $data = $this->raw(self::FIELD_CATEGORY_ORDER_HINTS);
322 if (is_null($data)) {
323 return null;
324 }
325
326 $this->categoryOrderHints = CategoryOrderHintsModel::of($data);
327 }
328
330 }
331
338 public function getMetaTitle()
339 {
340 if (is_null($this->metaTitle)) {
342 $data = $this->raw(self::FIELD_META_TITLE);
343 if (is_null($data)) {
344 return null;
345 }
346
347 $this->metaTitle = LocalizedStringModel::of($data);
348 }
349
350 return $this->metaTitle;
351 }
352
359 public function getMetaDescription()
360 {
361 if (is_null($this->metaDescription)) {
363 $data = $this->raw(self::FIELD_META_DESCRIPTION);
364 if (is_null($data)) {
365 return null;
366 }
367
368 $this->metaDescription = LocalizedStringModel::of($data);
369 }
370
372 }
373
380 public function getMetaKeywords()
381 {
382 if (is_null($this->metaKeywords)) {
384 $data = $this->raw(self::FIELD_META_KEYWORDS);
385 if (is_null($data)) {
386 return null;
387 }
388
389 $this->metaKeywords = LocalizedStringModel::of($data);
390 }
391
392 return $this->metaKeywords;
393 }
394
401 public function getMasterVariant()
402 {
403 if (is_null($this->masterVariant)) {
405 $data = $this->raw(self::FIELD_MASTER_VARIANT);
406 if (is_null($data)) {
407 return null;
408 }
409
410 $this->masterVariant = ProductVariantDraftModel::of($data);
411 }
412
414 }
415
422 public function getVariants()
423 {
424 if (is_null($this->variants)) {
426 $data = $this->raw(self::FIELD_VARIANTS);
427 if (is_null($data)) {
428 return null;
429 }
430 $this->variants = ProductVariantDraftCollection::fromArray($data);
431 }
432
433 return $this->variants;
434 }
435
442 public function getTaxCategory()
443 {
444 if (is_null($this->taxCategory)) {
446 $data = $this->raw(self::FIELD_TAX_CATEGORY);
447 if (is_null($data)) {
448 return null;
449 }
450
451 $this->taxCategory = TaxCategoryResourceIdentifierModel::of($data);
452 }
453
454 return $this->taxCategory;
455 }
456
463 public function getSearchKeywords()
464 {
465 if (is_null($this->searchKeywords)) {
467 $data = $this->raw(self::FIELD_SEARCH_KEYWORDS);
468 if (is_null($data)) {
469 return null;
470 }
471
472 $this->searchKeywords = SearchKeywordsModel::of($data);
473 }
474
476 }
477
484 public function getState()
485 {
486 if (is_null($this->state)) {
488 $data = $this->raw(self::FIELD_STATE);
489 if (is_null($data)) {
490 return null;
491 }
492
493 $this->state = StateResourceIdentifierModel::of($data);
494 }
495
496 return $this->state;
497 }
498
505 public function getPublish()
506 {
507 if (is_null($this->publish)) {
509 $data = $this->raw(self::FIELD_PUBLISH);
510 if (is_null($data)) {
511 return null;
512 }
513 $this->publish = (bool) $data;
514 }
515
516 return $this->publish;
517 }
518
525 public function getPriceMode()
526 {
527 if (is_null($this->priceMode)) {
529 $data = $this->raw(self::FIELD_PRICE_MODE);
530 if (is_null($data)) {
531 return null;
532 }
533 $this->priceMode = (string) $data;
534 }
535
536 return $this->priceMode;
537 }
538
546 public function getAttributes()
547 {
548 if (is_null($this->attributes)) {
550 $data = $this->raw(self::FIELD_ATTRIBUTES);
551 if (is_null($data)) {
552 return null;
553 }
554 $this->attributes = AttributeCollection::fromArray($data);
555 }
556
557 return $this->attributes;
558 }
559
560
565 {
566 $this->productType = $productType;
567 }
568
572 public function setName(?LocalizedString $name): void
573 {
574 $this->name = $name;
575 }
576
580 public function setSlug(?LocalizedString $slug): void
581 {
582 $this->slug = $slug;
583 }
584
588 public function setKey(?string $key): void
589 {
590 $this->key = $key;
591 }
592
597 {
598 $this->description = $description;
599 }
600
605 {
606 $this->categories = $categories;
607 }
608
613 {
614 $this->categoryOrderHints = $categoryOrderHints;
615 }
616
621 {
622 $this->metaTitle = $metaTitle;
623 }
624
629 {
630 $this->metaDescription = $metaDescription;
631 }
632
637 {
638 $this->metaKeywords = $metaKeywords;
639 }
640
645 {
646 $this->masterVariant = $masterVariant;
647 }
648
653 {
654 $this->variants = $variants;
655 }
656
661 {
662 $this->taxCategory = $taxCategory;
663 }
664
669 {
670 $this->searchKeywords = $searchKeywords;
671 }
672
677 {
678 $this->state = $state;
679 }
680
684 public function setPublish(?bool $publish): void
685 {
686 $this->publish = $publish;
687 }
688
692 public function setPriceMode(?string $priceMode): void
693 {
694 $this->priceMode = $priceMode;
695 }
696
701 {
702 $this->attributes = $attributes;
703 }
704}
setProductType(?ProductTypeResourceIdentifier $productType)
setVariants(?ProductVariantDraftCollection $variants)
__construct(?ProductTypeResourceIdentifier $productType=null, ?LocalizedString $name=null, ?LocalizedString $slug=null, ?string $key=null, ?LocalizedString $description=null, ?CategoryResourceIdentifierCollection $categories=null, ?CategoryOrderHints $categoryOrderHints=null, ?LocalizedString $metaTitle=null, ?LocalizedString $metaDescription=null, ?LocalizedString $metaKeywords=null, ?ProductVariantDraft $masterVariant=null, ?ProductVariantDraftCollection $variants=null, ?TaxCategoryResourceIdentifier $taxCategory=null, ?SearchKeywords $searchKeywords=null, ?StateResourceIdentifier $state=null, ?bool $publish=null, ?string $priceMode=null, ?AttributeCollection $attributes=null)
setMetaDescription(?LocalizedString $metaDescription)
setMasterVariant(?ProductVariantDraft $masterVariant)
setCategories(?CategoryResourceIdentifierCollection $categories)
setCategoryOrderHints(?CategoryOrderHints $categoryOrderHints)
setTaxCategory(?TaxCategoryResourceIdentifier $taxCategory)
static of($data=null)
static fromArray(array $data)