commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductDataModel.php
1<?php
2
3declare(strict_types=1);
10
18use stdClass;
19
23final class ProductDataModel extends JsonObjectModel implements ProductData
24{
29 protected $name;
30
35 protected $categories;
36
42
47 protected $description;
48
53 protected $slug;
54
59 protected $metaTitle;
60
66
71 protected $metaKeywords;
72
77 protected $masterVariant;
78
83 protected $variants;
84
89 protected $searchKeywords;
90
95 protected $attributes;
96
97
101 public function __construct(
102 ?LocalizedString $name = null,
106 ?LocalizedString $slug = null,
114 ) {
115 $this->name = $name;
116 $this->categories = $categories;
117 $this->categoryOrderHints = $categoryOrderHints;
118 $this->description = $description;
119 $this->slug = $slug;
120 $this->metaTitle = $metaTitle;
121 $this->metaDescription = $metaDescription;
122 $this->metaKeywords = $metaKeywords;
123 $this->masterVariant = $masterVariant;
124 $this->variants = $variants;
125 $this->searchKeywords = $searchKeywords;
126 $this->attributes = $attributes;
127 }
128
135 public function getName()
136 {
137 if (is_null($this->name)) {
139 $data = $this->raw(self::FIELD_NAME);
140 if (is_null($data)) {
141 return null;
142 }
143
144 $this->name = LocalizedStringModel::of($data);
145 }
146
147 return $this->name;
148 }
149
156 public function getCategories()
157 {
158 if (is_null($this->categories)) {
160 $data = $this->raw(self::FIELD_CATEGORIES);
161 if (is_null($data)) {
162 return null;
163 }
164 $this->categories = CategoryReferenceCollection::fromArray($data);
165 }
166
167 return $this->categories;
168 }
169
176 public function getCategoryOrderHints()
177 {
178 if (is_null($this->categoryOrderHints)) {
180 $data = $this->raw(self::FIELD_CATEGORY_ORDER_HINTS);
181 if (is_null($data)) {
182 return null;
183 }
184
185 $this->categoryOrderHints = CategoryOrderHintsModel::of($data);
186 }
187
189 }
190
197 public function getDescription()
198 {
199 if (is_null($this->description)) {
201 $data = $this->raw(self::FIELD_DESCRIPTION);
202 if (is_null($data)) {
203 return null;
204 }
205
206 $this->description = LocalizedStringModel::of($data);
207 }
208
209 return $this->description;
210 }
211
220 public function getSlug()
221 {
222 if (is_null($this->slug)) {
224 $data = $this->raw(self::FIELD_SLUG);
225 if (is_null($data)) {
226 return null;
227 }
228
229 $this->slug = LocalizedStringModel::of($data);
230 }
231
232 return $this->slug;
233 }
234
241 public function getMetaTitle()
242 {
243 if (is_null($this->metaTitle)) {
245 $data = $this->raw(self::FIELD_META_TITLE);
246 if (is_null($data)) {
247 return null;
248 }
249
250 $this->metaTitle = LocalizedStringModel::of($data);
251 }
252
253 return $this->metaTitle;
254 }
255
262 public function getMetaDescription()
263 {
264 if (is_null($this->metaDescription)) {
266 $data = $this->raw(self::FIELD_META_DESCRIPTION);
267 if (is_null($data)) {
268 return null;
269 }
270
271 $this->metaDescription = LocalizedStringModel::of($data);
272 }
273
275 }
276
283 public function getMetaKeywords()
284 {
285 if (is_null($this->metaKeywords)) {
287 $data = $this->raw(self::FIELD_META_KEYWORDS);
288 if (is_null($data)) {
289 return null;
290 }
291
292 $this->metaKeywords = LocalizedStringModel::of($data);
293 }
294
295 return $this->metaKeywords;
296 }
297
304 public function getMasterVariant()
305 {
306 if (is_null($this->masterVariant)) {
308 $data = $this->raw(self::FIELD_MASTER_VARIANT);
309 if (is_null($data)) {
310 return null;
311 }
312
313 $this->masterVariant = ProductVariantModel::of($data);
314 }
315
317 }
318
325 public function getVariants()
326 {
327 if (is_null($this->variants)) {
329 $data = $this->raw(self::FIELD_VARIANTS);
330 if (is_null($data)) {
331 return null;
332 }
333 $this->variants = ProductVariantCollection::fromArray($data);
334 }
335
336 return $this->variants;
337 }
338
345 public function getSearchKeywords()
346 {
347 if (is_null($this->searchKeywords)) {
349 $data = $this->raw(self::FIELD_SEARCH_KEYWORDS);
350 if (is_null($data)) {
351 return null;
352 }
353
354 $this->searchKeywords = SearchKeywordsModel::of($data);
355 }
356
358 }
359
367 public function getAttributes()
368 {
369 if (is_null($this->attributes)) {
371 $data = $this->raw(self::FIELD_ATTRIBUTES);
372 if (is_null($data)) {
373 return null;
374 }
375 $this->attributes = AttributeCollection::fromArray($data);
376 }
377
378 return $this->attributes;
379 }
380
381
385 public function setName(?LocalizedString $name): void
386 {
387 $this->name = $name;
388 }
389
394 {
395 $this->categories = $categories;
396 }
397
402 {
403 $this->categoryOrderHints = $categoryOrderHints;
404 }
405
410 {
411 $this->description = $description;
412 }
413
417 public function setSlug(?LocalizedString $slug): void
418 {
419 $this->slug = $slug;
420 }
421
426 {
427 $this->metaTitle = $metaTitle;
428 }
429
434 {
435 $this->metaDescription = $metaDescription;
436 }
437
442 {
443 $this->metaKeywords = $metaKeywords;
444 }
445
450 {
451 $this->masterVariant = $masterVariant;
452 }
453
458 {
459 $this->variants = $variants;
460 }
461
466 {
467 $this->searchKeywords = $searchKeywords;
468 }
469
474 {
475 $this->attributes = $attributes;
476 }
477}
setSearchKeywords(?SearchKeywords $searchKeywords)
setCategories(?CategoryReferenceCollection $categories)
__construct(?LocalizedString $name=null, ?CategoryReferenceCollection $categories=null, ?CategoryOrderHints $categoryOrderHints=null, ?LocalizedString $description=null, ?LocalizedString $slug=null, ?LocalizedString $metaTitle=null, ?LocalizedString $metaDescription=null, ?LocalizedString $metaKeywords=null, ?ProductVariant $masterVariant=null, ?ProductVariantCollection $variants=null, ?SearchKeywords $searchKeywords=null, ?AttributeCollection $attributes=null)
setCategoryOrderHints(?CategoryOrderHints $categoryOrderHints)
setAttributes(?AttributeCollection $attributes)
setVariants(?ProductVariantCollection $variants)
setMetaDescription(?LocalizedString $metaDescription)
static of($data=null)
static fromArray(array $data)