commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
VariantDataModel.php
1<?php
2
3declare(strict_types=1);
10
18use stdClass;
19
23final class VariantDataModel extends JsonObjectModel implements VariantData
24{
29 protected $sku;
30
35 protected $images;
36
41 protected $attributes;
42
47 protected $assets;
48
49
53 public function __construct(
54 ?string $sku = null,
58 ) {
59 $this->sku = $sku;
60 $this->images = $images;
61 $this->attributes = $attributes;
62 $this->assets = $assets;
63 }
64
71 public function getSku()
72 {
73 if (is_null($this->sku)) {
75 $data = $this->raw(self::FIELD_SKU);
76 if (is_null($data)) {
77 return null;
78 }
79 $this->sku = (string) $data;
80 }
81
82 return $this->sku;
83 }
84
91 public function getImages()
92 {
93 if (is_null($this->images)) {
95 $data = $this->raw(self::FIELD_IMAGES);
96 if (is_null($data)) {
97 return null;
98 }
99 $this->images = ImageCollection::fromArray($data);
100 }
101
102 return $this->images;
103 }
104
111 public function getAttributes()
112 {
113 if (is_null($this->attributes)) {
115 $data = $this->raw(self::FIELD_ATTRIBUTES);
116 if (is_null($data)) {
117 return null;
118 }
119 $this->attributes = AttributeCollection::fromArray($data);
120 }
121
122 return $this->attributes;
123 }
124
131 public function getAssets()
132 {
133 if (is_null($this->assets)) {
135 $data = $this->raw(self::FIELD_ASSETS);
136 if (is_null($data)) {
137 return null;
138 }
139 $this->assets = AssetCollection::fromArray($data);
140 }
141
142 return $this->assets;
143 }
144
145
149 public function setSku(?string $sku): void
150 {
151 $this->sku = $sku;
152 }
153
157 public function setImages(?ImageCollection $images): void
158 {
159 $this->images = $images;
160 }
161
166 {
167 $this->attributes = $attributes;
168 }
169
173 public function setAssets(?AssetCollection $assets): void
174 {
175 $this->assets = $assets;
176 }
177}
__construct(?string $sku=null, ?ImageCollection $images=null, ?AttributeCollection $attributes=null, ?AssetCollection $assets=null)
setAttributes(?AttributeCollection $attributes)