commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
VariantAttributesModel.php
1<?php
2
3declare(strict_types=1);
10
15use stdClass;
16
21{
26 protected $productId;
27
32 protected $productKey;
33
38 protected $attributes;
39
44 protected $variants;
45
46
50 public function __construct(
51 ?string $productId = null,
52 ?string $productKey = null,
55 ) {
56 $this->productId = $productId;
57 $this->productKey = $productKey;
58 $this->attributes = $attributes;
59 $this->variants = $variants;
60 }
61
68 public function getProductId()
69 {
70 if (is_null($this->productId)) {
72 $data = $this->raw(self::FIELD_PRODUCT_ID);
73 if (is_null($data)) {
74 return null;
75 }
76 $this->productId = (string) $data;
77 }
78
79 return $this->productId;
80 }
81
88 public function getProductKey()
89 {
90 if (is_null($this->productKey)) {
92 $data = $this->raw(self::FIELD_PRODUCT_KEY);
93 if (is_null($data)) {
94 return null;
95 }
96 $this->productKey = (string) $data;
97 }
98
99 return $this->productKey;
100 }
101
109 public function getAttributes()
110 {
111 if (is_null($this->attributes)) {
113 $data = $this->raw(self::FIELD_ATTRIBUTES);
114 if (is_null($data)) {
115 return null;
116 }
118 }
119
120 return $this->attributes;
121 }
122
129 public function getVariants()
130 {
131 if (is_null($this->variants)) {
133 $data = $this->raw(self::FIELD_VARIANTS);
134 if (is_null($data)) {
135 return null;
136 }
137 $this->variants = VariantAttributesVariantCollection::fromArray($data);
138 }
139
140 return $this->variants;
141 }
142
143
147 public function setProductId(?string $productId): void
148 {
149 $this->productId = $productId;
150 }
151
155 public function setProductKey(?string $productKey): void
156 {
157 $this->productKey = $productKey;
158 }
159
164 {
165 $this->attributes = $attributes;
166 }
167
172 {
173 $this->variants = $variants;
174 }
175}
__construct(?string $productId=null, ?string $productKey=null, ?VariantAttributesAttributeMetadataCollection $attributes=null, ?VariantAttributesVariantCollection $variants=null)
setAttributes(?VariantAttributesAttributeMetadataCollection $attributes)
static fromArray(array $data)