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
255 public function getKey()
256 {
257 if (is_null($this->key)) {
259 $data = $this->raw(self::FIELD_KEY);
260 if (is_null($data)) {
261 return null;
262 }
263 $this->key = (string) $data;
264 }
265
266 return $this->key;
267 }
268
275 public function getDescription()
276 {
277 if (is_null($this->description)) {
279 $data = $this->raw(self::FIELD_DESCRIPTION);
280 if (is_null($data)) {
281 return null;
282 }
283
284 $this->description = LocalizedStringModel::of($data);
285 }
286
287 return $this->description;
288 }
289
296 public function getCategories()
297 {
298 if (is_null($this->categories)) {
300 $data = $this->raw(self::FIELD_CATEGORIES);
301 if (is_null($data)) {
302 return null;
303 }
304 $this->categories = CategoryResourceIdentifierCollection::fromArray($data);
305 }
306
307 return $this->categories;
308 }
309
316 public function getCategoryOrderHints()
317 {
318 if (is_null($this->categoryOrderHints)) {
320 $data = $this->raw(self::FIELD_CATEGORY_ORDER_HINTS);
321 if (is_null($data)) {
322 return null;
323 }
324
325 $this->categoryOrderHints = CategoryOrderHintsModel::of($data);
326 }
327
329 }
330
337 public function getMetaTitle()
338 {
339 if (is_null($this->metaTitle)) {
341 $data = $this->raw(self::FIELD_META_TITLE);
342 if (is_null($data)) {
343 return null;
344 }
345
346 $this->metaTitle = LocalizedStringModel::of($data);
347 }
348
349 return $this->metaTitle;
350 }
351
358 public function getMetaDescription()
359 {
360 if (is_null($this->metaDescription)) {
362 $data = $this->raw(self::FIELD_META_DESCRIPTION);
363 if (is_null($data)) {
364 return null;
365 }
366
367 $this->metaDescription = LocalizedStringModel::of($data);
368 }
369
371 }
372
379 public function getMetaKeywords()
380 {
381 if (is_null($this->metaKeywords)) {
383 $data = $this->raw(self::FIELD_META_KEYWORDS);
384 if (is_null($data)) {
385 return null;
386 }
387
388 $this->metaKeywords = LocalizedStringModel::of($data);
389 }
390
391 return $this->metaKeywords;
392 }
393
400 public function getMasterVariant()
401 {
402 if (is_null($this->masterVariant)) {
404 $data = $this->raw(self::FIELD_MASTER_VARIANT);
405 if (is_null($data)) {
406 return null;
407 }
408
409 $this->masterVariant = ProductVariantDraftModel::of($data);
410 }
411
413 }
414
421 public function getVariants()
422 {
423 if (is_null($this->variants)) {
425 $data = $this->raw(self::FIELD_VARIANTS);
426 if (is_null($data)) {
427 return null;
428 }
429 $this->variants = ProductVariantDraftCollection::fromArray($data);
430 }
431
432 return $this->variants;
433 }
434
441 public function getTaxCategory()
442 {
443 if (is_null($this->taxCategory)) {
445 $data = $this->raw(self::FIELD_TAX_CATEGORY);
446 if (is_null($data)) {
447 return null;
448 }
449
450 $this->taxCategory = TaxCategoryResourceIdentifierModel::of($data);
451 }
452
453 return $this->taxCategory;
454 }
455
462 public function getSearchKeywords()
463 {
464 if (is_null($this->searchKeywords)) {
466 $data = $this->raw(self::FIELD_SEARCH_KEYWORDS);
467 if (is_null($data)) {
468 return null;
469 }
470
471 $this->searchKeywords = SearchKeywordsModel::of($data);
472 }
473
475 }
476
483 public function getState()
484 {
485 if (is_null($this->state)) {
487 $data = $this->raw(self::FIELD_STATE);
488 if (is_null($data)) {
489 return null;
490 }
491
492 $this->state = StateResourceIdentifierModel::of($data);
493 }
494
495 return $this->state;
496 }
497
506 public function getPublish()
507 {
508 if (is_null($this->publish)) {
510 $data = $this->raw(self::FIELD_PUBLISH);
511 if (is_null($data)) {
512 return null;
513 }
514 $this->publish = (bool) $data;
515 }
516
517 return $this->publish;
518 }
519
526 public function getPriceMode()
527 {
528 if (is_null($this->priceMode)) {
530 $data = $this->raw(self::FIELD_PRICE_MODE);
531 if (is_null($data)) {
532 return null;
533 }
534 $this->priceMode = (string) $data;
535 }
536
537 return $this->priceMode;
538 }
539
547 public function getAttributes()
548 {
549 if (is_null($this->attributes)) {
551 $data = $this->raw(self::FIELD_ATTRIBUTES);
552 if (is_null($data)) {
553 return null;
554 }
555 $this->attributes = AttributeCollection::fromArray($data);
556 }
557
558 return $this->attributes;
559 }
560
561
566 {
567 $this->productType = $productType;
568 }
569
573 public function setName(?LocalizedString $name): void
574 {
575 $this->name = $name;
576 }
577
581 public function setSlug(?LocalizedString $slug): void
582 {
583 $this->slug = $slug;
584 }
585
589 public function setKey(?string $key): void
590 {
591 $this->key = $key;
592 }
593
598 {
599 $this->description = $description;
600 }
601
606 {
607 $this->categories = $categories;
608 }
609
614 {
615 $this->categoryOrderHints = $categoryOrderHints;
616 }
617
622 {
623 $this->metaTitle = $metaTitle;
624 }
625
630 {
631 $this->metaDescription = $metaDescription;
632 }
633
638 {
639 $this->metaKeywords = $metaKeywords;
640 }
641
646 {
647 $this->masterVariant = $masterVariant;
648 }
649
654 {
655 $this->variants = $variants;
656 }
657
662 {
663 $this->taxCategory = $taxCategory;
664 }
665
670 {
671 $this->searchKeywords = $searchKeywords;
672 }
673
678 {
679 $this->state = $state;
680 }
681
685 public function setPublish(?bool $publish): void
686 {
687 $this->publish = $publish;
688 }
689
693 public function setPriceMode(?string $priceMode): void
694 {
695 $this->priceMode = $priceMode;
696 }
697
702 {
703 $this->attributes = $attributes;
704 }
705}
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)