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
91
95 public function __construct(
96 ?LocalizedString $name = null,
100 ?LocalizedString $slug = null,
107 ) {
108 $this->name = $name;
109 $this->categories = $categories;
110 $this->categoryOrderHints = $categoryOrderHints;
111 $this->description = $description;
112 $this->slug = $slug;
113 $this->metaTitle = $metaTitle;
114 $this->metaDescription = $metaDescription;
115 $this->metaKeywords = $metaKeywords;
116 $this->masterVariant = $masterVariant;
117 $this->variants = $variants;
118 $this->searchKeywords = $searchKeywords;
119 }
120
127 public function getName()
128 {
129 if (is_null($this->name)) {
131 $data = $this->raw(self::FIELD_NAME);
132 if (is_null($data)) {
133 return null;
134 }
135
136 $this->name = LocalizedStringModel::of($data);
137 }
138
139 return $this->name;
140 }
141
148 public function getCategories()
149 {
150 if (is_null($this->categories)) {
152 $data = $this->raw(self::FIELD_CATEGORIES);
153 if (is_null($data)) {
154 return null;
155 }
156 $this->categories = CategoryReferenceCollection::fromArray($data);
157 }
158
159 return $this->categories;
160 }
161
168 public function getCategoryOrderHints()
169 {
170 if (is_null($this->categoryOrderHints)) {
172 $data = $this->raw(self::FIELD_CATEGORY_ORDER_HINTS);
173 if (is_null($data)) {
174 return null;
175 }
176
177 $this->categoryOrderHints = CategoryOrderHintsModel::of($data);
178 }
179
181 }
182
189 public function getDescription()
190 {
191 if (is_null($this->description)) {
193 $data = $this->raw(self::FIELD_DESCRIPTION);
194 if (is_null($data)) {
195 return null;
196 }
197
198 $this->description = LocalizedStringModel::of($data);
199 }
200
201 return $this->description;
202 }
203
212 public function getSlug()
213 {
214 if (is_null($this->slug)) {
216 $data = $this->raw(self::FIELD_SLUG);
217 if (is_null($data)) {
218 return null;
219 }
220
221 $this->slug = LocalizedStringModel::of($data);
222 }
223
224 return $this->slug;
225 }
226
233 public function getMetaTitle()
234 {
235 if (is_null($this->metaTitle)) {
237 $data = $this->raw(self::FIELD_META_TITLE);
238 if (is_null($data)) {
239 return null;
240 }
241
242 $this->metaTitle = LocalizedStringModel::of($data);
243 }
244
245 return $this->metaTitle;
246 }
247
254 public function getMetaDescription()
255 {
256 if (is_null($this->metaDescription)) {
258 $data = $this->raw(self::FIELD_META_DESCRIPTION);
259 if (is_null($data)) {
260 return null;
261 }
262
263 $this->metaDescription = LocalizedStringModel::of($data);
264 }
265
267 }
268
275 public function getMetaKeywords()
276 {
277 if (is_null($this->metaKeywords)) {
279 $data = $this->raw(self::FIELD_META_KEYWORDS);
280 if (is_null($data)) {
281 return null;
282 }
283
284 $this->metaKeywords = LocalizedStringModel::of($data);
285 }
286
287 return $this->metaKeywords;
288 }
289
296 public function getMasterVariant()
297 {
298 if (is_null($this->masterVariant)) {
300 $data = $this->raw(self::FIELD_MASTER_VARIANT);
301 if (is_null($data)) {
302 return null;
303 }
304
305 $this->masterVariant = ProductVariantModel::of($data);
306 }
307
309 }
310
317 public function getVariants()
318 {
319 if (is_null($this->variants)) {
321 $data = $this->raw(self::FIELD_VARIANTS);
322 if (is_null($data)) {
323 return null;
324 }
325 $this->variants = ProductVariantCollection::fromArray($data);
326 }
327
328 return $this->variants;
329 }
330
337 public function getSearchKeywords()
338 {
339 if (is_null($this->searchKeywords)) {
341 $data = $this->raw(self::FIELD_SEARCH_KEYWORDS);
342 if (is_null($data)) {
343 return null;
344 }
345
346 $this->searchKeywords = SearchKeywordsModel::of($data);
347 }
348
350 }
351
352
356 public function setName(?LocalizedString $name): void
357 {
358 $this->name = $name;
359 }
360
365 {
366 $this->categories = $categories;
367 }
368
373 {
374 $this->categoryOrderHints = $categoryOrderHints;
375 }
376
381 {
382 $this->description = $description;
383 }
384
388 public function setSlug(?LocalizedString $slug): void
389 {
390 $this->slug = $slug;
391 }
392
397 {
398 $this->metaTitle = $metaTitle;
399 }
400
405 {
406 $this->metaDescription = $metaDescription;
407 }
408
413 {
414 $this->metaKeywords = $metaKeywords;
415 }
416
421 {
422 $this->masterVariant = $masterVariant;
423 }
424
429 {
430 $this->variants = $variants;
431 }
432
437 {
438 $this->searchKeywords = $searchKeywords;
439 }
440}
__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)
setSearchKeywords(?SearchKeywords $searchKeywords)
setCategories(?CategoryReferenceCollection $categories)
setCategoryOrderHints(?CategoryOrderHints $categoryOrderHints)
setVariants(?ProductVariantCollection $variants)
setMetaDescription(?LocalizedString $metaDescription)
static of($data=null)
static fromArray(array $data)