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
20use stdClass;
21
25final class ProductDataModel extends JsonObjectModel implements ProductData
26{
31 protected $name;
32
37 protected $categories;
38
44
49 protected $description;
50
55 protected $slug;
56
61 protected $metaTitle;
62
68
73 protected $metaKeywords;
74
79 protected $masterVariant;
80
85 protected $variants;
86
91 protected $searchKeywords;
92
97 protected $attributes;
98
104
105
109 public function __construct(
110 ?LocalizedString $name = null,
114 ?LocalizedString $slug = null,
123 ) {
124 $this->name = $name;
125 $this->categories = $categories;
126 $this->categoryOrderHints = $categoryOrderHints;
127 $this->description = $description;
128 $this->slug = $slug;
129 $this->metaTitle = $metaTitle;
130 $this->metaDescription = $metaDescription;
131 $this->metaKeywords = $metaKeywords;
132 $this->masterVariant = $masterVariant;
133 $this->variants = $variants;
134 $this->searchKeywords = $searchKeywords;
135 $this->attributes = $attributes;
136 $this->defaultVariant = $defaultVariant;
137 }
138
145 public function getName()
146 {
147 if (is_null($this->name)) {
149 $data = $this->raw(self::FIELD_NAME);
150 if (is_null($data)) {
151 return null;
152 }
153
154 $this->name = LocalizedStringModel::of($data);
155 }
156
157 return $this->name;
158 }
159
166 public function getCategories()
167 {
168 if (is_null($this->categories)) {
170 $data = $this->raw(self::FIELD_CATEGORIES);
171 if (is_null($data)) {
172 return null;
173 }
174 $this->categories = CategoryReferenceCollection::fromArray($data);
175 }
176
177 return $this->categories;
178 }
179
186 public function getCategoryOrderHints()
187 {
188 if (is_null($this->categoryOrderHints)) {
190 $data = $this->raw(self::FIELD_CATEGORY_ORDER_HINTS);
191 if (is_null($data)) {
192 return null;
193 }
194
195 $this->categoryOrderHints = CategoryOrderHintsModel::of($data);
196 }
197
199 }
200
207 public function getDescription()
208 {
209 if (is_null($this->description)) {
211 $data = $this->raw(self::FIELD_DESCRIPTION);
212 if (is_null($data)) {
213 return null;
214 }
215
216 $this->description = LocalizedStringModel::of($data);
217 }
218
219 return $this->description;
220 }
221
230 public function getSlug()
231 {
232 if (is_null($this->slug)) {
234 $data = $this->raw(self::FIELD_SLUG);
235 if (is_null($data)) {
236 return null;
237 }
238
239 $this->slug = LocalizedStringModel::of($data);
240 }
241
242 return $this->slug;
243 }
244
251 public function getMetaTitle()
252 {
253 if (is_null($this->metaTitle)) {
255 $data = $this->raw(self::FIELD_META_TITLE);
256 if (is_null($data)) {
257 return null;
258 }
259
260 $this->metaTitle = LocalizedStringModel::of($data);
261 }
262
263 return $this->metaTitle;
264 }
265
272 public function getMetaDescription()
273 {
274 if (is_null($this->metaDescription)) {
276 $data = $this->raw(self::FIELD_META_DESCRIPTION);
277 if (is_null($data)) {
278 return null;
279 }
280
281 $this->metaDescription = LocalizedStringModel::of($data);
282 }
283
285 }
286
293 public function getMetaKeywords()
294 {
295 if (is_null($this->metaKeywords)) {
297 $data = $this->raw(self::FIELD_META_KEYWORDS);
298 if (is_null($data)) {
299 return null;
300 }
301
302 $this->metaKeywords = LocalizedStringModel::of($data);
303 }
304
305 return $this->metaKeywords;
306 }
307
315 public function getMasterVariant()
316 {
317 if (is_null($this->masterVariant)) {
319 $data = $this->raw(self::FIELD_MASTER_VARIANT);
320 if (is_null($data)) {
321 return null;
322 }
323
324 $this->masterVariant = ProductVariantModel::of($data);
325 }
326
328 }
329
337 public function getVariants()
338 {
339 if (is_null($this->variants)) {
341 $data = $this->raw(self::FIELD_VARIANTS);
342 if (is_null($data)) {
343 return null;
344 }
345 $this->variants = ProductVariantCollection::fromArray($data);
346 }
347
348 return $this->variants;
349 }
350
357 public function getSearchKeywords()
358 {
359 if (is_null($this->searchKeywords)) {
361 $data = $this->raw(self::FIELD_SEARCH_KEYWORDS);
362 if (is_null($data)) {
363 return null;
364 }
365
366 $this->searchKeywords = SearchKeywordsModel::of($data);
367 }
368
370 }
371
379 public function getAttributes()
380 {
381 if (is_null($this->attributes)) {
383 $data = $this->raw(self::FIELD_ATTRIBUTES);
384 if (is_null($data)) {
385 return null;
386 }
387 $this->attributes = AttributeCollection::fromArray($data);
388 }
389
390 return $this->attributes;
391 }
392
399 public function getDefaultVariant()
400 {
401 if (is_null($this->defaultVariant)) {
403 $data = $this->raw(self::FIELD_DEFAULT_VARIANT);
404 if (is_null($data)) {
405 return null;
406 }
407
408 $this->defaultVariant = VariantReferenceModel::of($data);
409 }
410
412 }
413
414
418 public function setName(?LocalizedString $name): void
419 {
420 $this->name = $name;
421 }
422
427 {
428 $this->categories = $categories;
429 }
430
435 {
436 $this->categoryOrderHints = $categoryOrderHints;
437 }
438
443 {
444 $this->description = $description;
445 }
446
450 public function setSlug(?LocalizedString $slug): void
451 {
452 $this->slug = $slug;
453 }
454
459 {
460 $this->metaTitle = $metaTitle;
461 }
462
467 {
468 $this->metaDescription = $metaDescription;
469 }
470
475 {
476 $this->metaKeywords = $metaKeywords;
477 }
478
483 {
484 $this->masterVariant = $masterVariant;
485 }
486
491 {
492 $this->variants = $variants;
493 }
494
499 {
500 $this->searchKeywords = $searchKeywords;
501 }
502
507 {
508 $this->attributes = $attributes;
509 }
510
515 {
516 $this->defaultVariant = $defaultVariant;
517 }
518}
setDefaultVariant(?VariantReference $defaultVariant)
setSearchKeywords(?SearchKeywords $searchKeywords)
__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, ?VariantReference $defaultVariant=null)
setCategories(?CategoryReferenceCollection $categories)
setCategoryOrderHints(?CategoryOrderHints $categoryOrderHints)
setAttributes(?AttributeCollection $attributes)
setVariants(?ProductVariantCollection $variants)
setMetaDescription(?LocalizedString $metaDescription)
static of($data=null)
static fromArray(array $data)