commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ProductVariantDraftModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
24 {
29  protected $sku;
30 
35  protected $key;
36 
41  protected $prices;
42 
47  protected $attributes;
48 
53  protected $images;
54 
59  protected $assets;
60 
61 
65  public function __construct(
66  ?string $sku = null,
67  ?string $key = null,
70  ?ImageCollection $images = null,
72  ) {
73  $this->sku = $sku;
74  $this->key = $key;
75  $this->prices = $prices;
76  $this->attributes = $attributes;
77  $this->images = $images;
78  $this->assets = $assets;
79  }
80 
87  public function getSku()
88  {
89  if (is_null($this->sku)) {
91  $data = $this->raw(self::FIELD_SKU);
92  if (is_null($data)) {
93  return null;
94  }
95  $this->sku = (string) $data;
96  }
97 
98  return $this->sku;
99  }
100 
107  public function getKey()
108  {
109  if (is_null($this->key)) {
111  $data = $this->raw(self::FIELD_KEY);
112  if (is_null($data)) {
113  return null;
114  }
115  $this->key = (string) $data;
116  }
117 
118  return $this->key;
119  }
120 
128  public function getPrices()
129  {
130  if (is_null($this->prices)) {
132  $data = $this->raw(self::FIELD_PRICES);
133  if (is_null($data)) {
134  return null;
135  }
136  $this->prices = PriceDraftCollection::fromArray($data);
137  }
138 
139  return $this->prices;
140  }
141 
148  public function getAttributes()
149  {
150  if (is_null($this->attributes)) {
152  $data = $this->raw(self::FIELD_ATTRIBUTES);
153  if (is_null($data)) {
154  return null;
155  }
156  $this->attributes = AttributeCollection::fromArray($data);
157  }
158 
159  return $this->attributes;
160  }
161 
168  public function getImages()
169  {
170  if (is_null($this->images)) {
172  $data = $this->raw(self::FIELD_IMAGES);
173  if (is_null($data)) {
174  return null;
175  }
176  $this->images = ImageCollection::fromArray($data);
177  }
178 
179  return $this->images;
180  }
181 
188  public function getAssets()
189  {
190  if (is_null($this->assets)) {
192  $data = $this->raw(self::FIELD_ASSETS);
193  if (is_null($data)) {
194  return null;
195  }
196  $this->assets = AssetDraftCollection::fromArray($data);
197  }
198 
199  return $this->assets;
200  }
201 
202 
206  public function setSku(?string $sku): void
207  {
208  $this->sku = $sku;
209  }
210 
214  public function setKey(?string $key): void
215  {
216  $this->key = $key;
217  }
218 
222  public function setPrices(?PriceDraftCollection $prices): void
223  {
224  $this->prices = $prices;
225  }
226 
231  {
232  $this->attributes = $attributes;
233  }
234 
238  public function setImages(?ImageCollection $images): void
239  {
240  $this->images = $images;
241  }
242 
246  public function setAssets(?AssetDraftCollection $assets): void
247  {
248  $this->assets = $assets;
249  }
250 }
__construct(?string $sku=null, ?string $key=null, ?PriceDraftCollection $prices=null, ?AttributeCollection $attributes=null, ?ImageCollection $images=null, ?AssetDraftCollection $assets=null)