commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductProjectionModel.php
1<?php
2
3declare(strict_types=1);
10
28use DateTimeImmutable;
29use stdClass;
30
35{
40 protected $id;
41
46 protected $version;
47
52 protected $createdAt;
53
58 protected $lastModifiedAt;
59
64 protected $key;
65
70 protected $productType;
71
76 protected $name;
77
82 protected $description;
83
88 protected $slug;
89
94 protected $categories;
95
101
106 protected $metaTitle;
107
113
118 protected $metaKeywords;
119
125
131
136 protected $published;
137
142 protected $masterVariant;
143
148 protected $variants;
149
154 protected $taxCategory;
155
160 protected $state;
161
167
172 protected $priceMode;
173
178 protected $attributes;
179
180
184 public function __construct(
185 ?string $id = null,
186 ?int $version = null,
187 ?DateTimeImmutable $createdAt = null,
188 ?DateTimeImmutable $lastModifiedAt = null,
189 ?string $key = null,
191 ?LocalizedString $name = null,
193 ?LocalizedString $slug = null,
200 ?bool $hasStagedChanges = null,
201 ?bool $published = null,
205 ?StateReference $state = null,
207 ?string $priceMode = null,
209 ) {
210 $this->id = $id;
211 $this->version = $version;
212 $this->createdAt = $createdAt;
213 $this->lastModifiedAt = $lastModifiedAt;
214 $this->key = $key;
215 $this->productType = $productType;
216 $this->name = $name;
217 $this->description = $description;
218 $this->slug = $slug;
219 $this->categories = $categories;
220 $this->categoryOrderHints = $categoryOrderHints;
221 $this->metaTitle = $metaTitle;
222 $this->metaDescription = $metaDescription;
223 $this->metaKeywords = $metaKeywords;
224 $this->searchKeywords = $searchKeywords;
225 $this->hasStagedChanges = $hasStagedChanges;
226 $this->published = $published;
227 $this->masterVariant = $masterVariant;
228 $this->variants = $variants;
229 $this->taxCategory = $taxCategory;
230 $this->state = $state;
231 $this->reviewRatingStatistics = $reviewRatingStatistics;
232 $this->priceMode = $priceMode;
233 $this->attributes = $attributes;
234 }
235
242 public function getId()
243 {
244 if (is_null($this->id)) {
246 $data = $this->raw(self::FIELD_ID);
247 if (is_null($data)) {
248 return null;
249 }
250 $this->id = (string) $data;
251 }
252
253 return $this->id;
254 }
255
262 public function getVersion()
263 {
264 if (is_null($this->version)) {
266 $data = $this->raw(self::FIELD_VERSION);
267 if (is_null($data)) {
268 return null;
269 }
270 $this->version = (int) $data;
271 }
272
273 return $this->version;
274 }
275
282 public function getCreatedAt()
283 {
284 if (is_null($this->createdAt)) {
286 $data = $this->raw(self::FIELD_CREATED_AT);
287 if (is_null($data)) {
288 return null;
289 }
290 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
291 if (false === $data) {
292 return null;
293 }
294 $this->createdAt = $data;
295 }
296
297 return $this->createdAt;
298 }
299
306 public function getLastModifiedAt()
307 {
308 if (is_null($this->lastModifiedAt)) {
310 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
311 if (is_null($data)) {
312 return null;
313 }
314 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
315 if (false === $data) {
316 return null;
317 }
318 $this->lastModifiedAt = $data;
319 }
320
322 }
323
330 public function getKey()
331 {
332 if (is_null($this->key)) {
334 $data = $this->raw(self::FIELD_KEY);
335 if (is_null($data)) {
336 return null;
337 }
338 $this->key = (string) $data;
339 }
340
341 return $this->key;
342 }
343
350 public function getProductType()
351 {
352 if (is_null($this->productType)) {
354 $data = $this->raw(self::FIELD_PRODUCT_TYPE);
355 if (is_null($data)) {
356 return null;
357 }
358
359 $this->productType = ProductTypeReferenceModel::of($data);
360 }
361
362 return $this->productType;
363 }
364
371 public function getName()
372 {
373 if (is_null($this->name)) {
375 $data = $this->raw(self::FIELD_NAME);
376 if (is_null($data)) {
377 return null;
378 }
379
380 $this->name = LocalizedStringModel::of($data);
381 }
382
383 return $this->name;
384 }
385
392 public function getDescription()
393 {
394 if (is_null($this->description)) {
396 $data = $this->raw(self::FIELD_DESCRIPTION);
397 if (is_null($data)) {
398 return null;
399 }
400
401 $this->description = LocalizedStringModel::of($data);
402 }
403
404 return $this->description;
405 }
406
416 public function getSlug()
417 {
418 if (is_null($this->slug)) {
420 $data = $this->raw(self::FIELD_SLUG);
421 if (is_null($data)) {
422 return null;
423 }
424
425 $this->slug = LocalizedStringModel::of($data);
426 }
427
428 return $this->slug;
429 }
430
437 public function getCategories()
438 {
439 if (is_null($this->categories)) {
441 $data = $this->raw(self::FIELD_CATEGORIES);
442 if (is_null($data)) {
443 return null;
444 }
445 $this->categories = CategoryReferenceCollection::fromArray($data);
446 }
447
448 return $this->categories;
449 }
450
457 public function getCategoryOrderHints()
458 {
459 if (is_null($this->categoryOrderHints)) {
461 $data = $this->raw(self::FIELD_CATEGORY_ORDER_HINTS);
462 if (is_null($data)) {
463 return null;
464 }
465
466 $this->categoryOrderHints = CategoryOrderHintsModel::of($data);
467 }
468
470 }
471
478 public function getMetaTitle()
479 {
480 if (is_null($this->metaTitle)) {
482 $data = $this->raw(self::FIELD_META_TITLE);
483 if (is_null($data)) {
484 return null;
485 }
486
487 $this->metaTitle = LocalizedStringModel::of($data);
488 }
489
490 return $this->metaTitle;
491 }
492
499 public function getMetaDescription()
500 {
501 if (is_null($this->metaDescription)) {
503 $data = $this->raw(self::FIELD_META_DESCRIPTION);
504 if (is_null($data)) {
505 return null;
506 }
507
508 $this->metaDescription = LocalizedStringModel::of($data);
509 }
510
512 }
513
520 public function getMetaKeywords()
521 {
522 if (is_null($this->metaKeywords)) {
524 $data = $this->raw(self::FIELD_META_KEYWORDS);
525 if (is_null($data)) {
526 return null;
527 }
528
529 $this->metaKeywords = LocalizedStringModel::of($data);
530 }
531
532 return $this->metaKeywords;
533 }
534
541 public function getSearchKeywords()
542 {
543 if (is_null($this->searchKeywords)) {
545 $data = $this->raw(self::FIELD_SEARCH_KEYWORDS);
546 if (is_null($data)) {
547 return null;
548 }
549
550 $this->searchKeywords = SearchKeywordsModel::of($data);
551 }
552
554 }
555
562 public function getHasStagedChanges()
563 {
564 if (is_null($this->hasStagedChanges)) {
566 $data = $this->raw(self::FIELD_HAS_STAGED_CHANGES);
567 if (is_null($data)) {
568 return null;
569 }
570 $this->hasStagedChanges = (bool) $data;
571 }
572
574 }
575
582 public function getPublished()
583 {
584 if (is_null($this->published)) {
586 $data = $this->raw(self::FIELD_PUBLISHED);
587 if (is_null($data)) {
588 return null;
589 }
590 $this->published = (bool) $data;
591 }
592
593 return $this->published;
594 }
595
602 public function getMasterVariant()
603 {
604 if (is_null($this->masterVariant)) {
606 $data = $this->raw(self::FIELD_MASTER_VARIANT);
607 if (is_null($data)) {
608 return null;
609 }
610
611 $this->masterVariant = ProductVariantModel::of($data);
612 }
613
615 }
616
623 public function getVariants()
624 {
625 if (is_null($this->variants)) {
627 $data = $this->raw(self::FIELD_VARIANTS);
628 if (is_null($data)) {
629 return null;
630 }
631 $this->variants = ProductVariantCollection::fromArray($data);
632 }
633
634 return $this->variants;
635 }
636
643 public function getTaxCategory()
644 {
645 if (is_null($this->taxCategory)) {
647 $data = $this->raw(self::FIELD_TAX_CATEGORY);
648 if (is_null($data)) {
649 return null;
650 }
651
652 $this->taxCategory = TaxCategoryReferenceModel::of($data);
653 }
654
655 return $this->taxCategory;
656 }
657
664 public function getState()
665 {
666 if (is_null($this->state)) {
668 $data = $this->raw(self::FIELD_STATE);
669 if (is_null($data)) {
670 return null;
671 }
672
673 $this->state = StateReferenceModel::of($data);
674 }
675
676 return $this->state;
677 }
678
686 {
687 if (is_null($this->reviewRatingStatistics)) {
689 $data = $this->raw(self::FIELD_REVIEW_RATING_STATISTICS);
690 if (is_null($data)) {
691 return null;
692 }
693
694 $this->reviewRatingStatistics = ReviewRatingStatisticsModel::of($data);
695 }
696
698 }
699
706 public function getPriceMode()
707 {
708 if (is_null($this->priceMode)) {
710 $data = $this->raw(self::FIELD_PRICE_MODE);
711 if (is_null($data)) {
712 return null;
713 }
714 $this->priceMode = (string) $data;
715 }
716
717 return $this->priceMode;
718 }
719
726 public function getAttributes()
727 {
728 if (is_null($this->attributes)) {
730 $data = $this->raw(self::FIELD_ATTRIBUTES);
731 if (is_null($data)) {
732 return null;
733 }
734 $this->attributes = AttributeCollection::fromArray($data);
735 }
736
737 return $this->attributes;
738 }
739
740
744 public function setId(?string $id): void
745 {
746 $this->id = $id;
747 }
748
752 public function setVersion(?int $version): void
753 {
754 $this->version = $version;
755 }
756
760 public function setCreatedAt(?DateTimeImmutable $createdAt): void
761 {
762 $this->createdAt = $createdAt;
763 }
764
768 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
769 {
770 $this->lastModifiedAt = $lastModifiedAt;
771 }
772
776 public function setKey(?string $key): void
777 {
778 $this->key = $key;
779 }
780
785 {
786 $this->productType = $productType;
787 }
788
792 public function setName(?LocalizedString $name): void
793 {
794 $this->name = $name;
795 }
796
801 {
802 $this->description = $description;
803 }
804
808 public function setSlug(?LocalizedString $slug): void
809 {
810 $this->slug = $slug;
811 }
812
817 {
818 $this->categories = $categories;
819 }
820
825 {
826 $this->categoryOrderHints = $categoryOrderHints;
827 }
828
833 {
834 $this->metaTitle = $metaTitle;
835 }
836
841 {
842 $this->metaDescription = $metaDescription;
843 }
844
849 {
850 $this->metaKeywords = $metaKeywords;
851 }
852
857 {
858 $this->searchKeywords = $searchKeywords;
859 }
860
864 public function setHasStagedChanges(?bool $hasStagedChanges): void
865 {
866 $this->hasStagedChanges = $hasStagedChanges;
867 }
868
872 public function setPublished(?bool $published): void
873 {
874 $this->published = $published;
875 }
876
881 {
882 $this->masterVariant = $masterVariant;
883 }
884
889 {
890 $this->variants = $variants;
891 }
892
897 {
898 $this->taxCategory = $taxCategory;
899 }
900
904 public function setState(?StateReference $state): void
905 {
906 $this->state = $state;
907 }
908
913 {
914 $this->reviewRatingStatistics = $reviewRatingStatistics;
915 }
916
920 public function setPriceMode(?string $priceMode): void
921 {
922 $this->priceMode = $priceMode;
923 }
924
929 {
930 $this->attributes = $attributes;
931 }
932
933
934 #[\ReturnTypeWillChange]
935 public function jsonSerialize()
936 {
937 $data = $this->toArray();
938 if (isset($data[ProductProjection::FIELD_CREATED_AT]) && $data[ProductProjection::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
939 $data[ProductProjection::FIELD_CREATED_AT] = $data[ProductProjection::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
940 }
941
942 if (isset($data[ProductProjection::FIELD_LAST_MODIFIED_AT]) && $data[ProductProjection::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
943 $data[ProductProjection::FIELD_LAST_MODIFIED_AT] = $data[ProductProjection::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
944 }
945 return (object) $data;
946 }
947}
setCategories(?CategoryReferenceCollection $categories)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?string $key=null, ?ProductTypeReference $productType=null, ?LocalizedString $name=null, ?LocalizedString $description=null, ?LocalizedString $slug=null, ?CategoryReferenceCollection $categories=null, ?CategoryOrderHints $categoryOrderHints=null, ?LocalizedString $metaTitle=null, ?LocalizedString $metaDescription=null, ?LocalizedString $metaKeywords=null, ?SearchKeywords $searchKeywords=null, ?bool $hasStagedChanges=null, ?bool $published=null, ?ProductVariant $masterVariant=null, ?ProductVariantCollection $variants=null, ?TaxCategoryReference $taxCategory=null, ?StateReference $state=null, ?ReviewRatingStatistics $reviewRatingStatistics=null, ?string $priceMode=null, ?AttributeCollection $attributes=null)
setReviewRatingStatistics(?ReviewRatingStatistics $reviewRatingStatistics)
setCategoryOrderHints(?CategoryOrderHints $categoryOrderHints)
static of($data=null)
static fromArray(array $data)