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
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
423 public function getVariants()
424 {
425 if (is_null($this->variants)) {
427 $data = $this->raw(self::FIELD_VARIANTS);
428 if (is_null($data)) {
429 return null;
430 }
431 $this->variants = ProductVariantDraftCollection::fromArray($data);
432 }
433
434 return $this->variants;
435 }
436
443 public function getTaxCategory()
444 {
445 if (is_null($this->taxCategory)) {
447 $data = $this->raw(self::FIELD_TAX_CATEGORY);
448 if (is_null($data)) {
449 return null;
450 }
451
452 $this->taxCategory = TaxCategoryResourceIdentifierModel::of($data);
453 }
454
455 return $this->taxCategory;
456 }
457
464 public function getSearchKeywords()
465 {
466 if (is_null($this->searchKeywords)) {
468 $data = $this->raw(self::FIELD_SEARCH_KEYWORDS);
469 if (is_null($data)) {
470 return null;
471 }
472
473 $this->searchKeywords = SearchKeywordsModel::of($data);
474 }
475
477 }
478
485 public function getState()
486 {
487 if (is_null($this->state)) {
489 $data = $this->raw(self::FIELD_STATE);
490 if (is_null($data)) {
491 return null;
492 }
493
494 $this->state = StateResourceIdentifierModel::of($data);
495 }
496
497 return $this->state;
498 }
499
508 public function getPublish()
509 {
510 if (is_null($this->publish)) {
512 $data = $this->raw(self::FIELD_PUBLISH);
513 if (is_null($data)) {
514 return null;
515 }
516 $this->publish = (bool) $data;
517 }
518
519 return $this->publish;
520 }
521
528 public function getPriceMode()
529 {
530 if (is_null($this->priceMode)) {
532 $data = $this->raw(self::FIELD_PRICE_MODE);
533 if (is_null($data)) {
534 return null;
535 }
536 $this->priceMode = (string) $data;
537 }
538
539 return $this->priceMode;
540 }
541
549 public function getAttributes()
550 {
551 if (is_null($this->attributes)) {
553 $data = $this->raw(self::FIELD_ATTRIBUTES);
554 if (is_null($data)) {
555 return null;
556 }
557 $this->attributes = AttributeCollection::fromArray($data);
558 }
559
560 return $this->attributes;
561 }
562
563
568 {
569 $this->productType = $productType;
570 }
571
575 public function setName(?LocalizedString $name): void
576 {
577 $this->name = $name;
578 }
579
583 public function setSlug(?LocalizedString $slug): void
584 {
585 $this->slug = $slug;
586 }
587
591 public function setKey(?string $key): void
592 {
593 $this->key = $key;
594 }
595
600 {
601 $this->description = $description;
602 }
603
608 {
609 $this->categories = $categories;
610 }
611
616 {
617 $this->categoryOrderHints = $categoryOrderHints;
618 }
619
624 {
625 $this->metaTitle = $metaTitle;
626 }
627
632 {
633 $this->metaDescription = $metaDescription;
634 }
635
640 {
641 $this->metaKeywords = $metaKeywords;
642 }
643
648 {
649 $this->masterVariant = $masterVariant;
650 }
651
656 {
657 $this->variants = $variants;
658 }
659
664 {
665 $this->taxCategory = $taxCategory;
666 }
667
672 {
673 $this->searchKeywords = $searchKeywords;
674 }
675
680 {
681 $this->state = $state;
682 }
683
687 public function setPublish(?bool $publish): void
688 {
689 $this->publish = $publish;
690 }
691
695 public function setPriceMode(?string $priceMode): void
696 {
697 $this->priceMode = $priceMode;
698 }
699
704 {
705 $this->attributes = $attributes;
706 }
707}
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)