|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jenschude <[email protected]> |
|
4
|
|
|
* @created: 04.02.15, 16:41 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Commercetools\Core\Model\Product; |
|
8
|
|
|
|
|
9
|
|
|
use Commercetools\Core\Model\Common\AttributeCollection; |
|
10
|
|
|
use Commercetools\Core\Model\Common\Context; |
|
11
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
|
12
|
|
|
use Commercetools\Core\Model\Common\PriceDraft; |
|
13
|
|
|
use Commercetools\Core\Model\Common\PriceDraftCollection; |
|
14
|
|
|
use Commercetools\Core\Model\Common\ImageCollection; |
|
15
|
|
|
use Commercetools\Core\Model\Common\AssetDraftCollection; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @package Commercetools\Core\Model\Product |
|
19
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#productvariantdraft |
|
20
|
|
|
* @method string getSku() |
|
21
|
|
|
* @method ProductVariantDraft setSku(string $sku = null) |
|
22
|
|
|
* @method ProductVariantDraft setPrices(PriceDraftCollection $prices = null) |
|
23
|
|
|
* @method ProductVariantDraft setAttributes(AttributeCollection $attributes = null) |
|
24
|
|
|
* @method PriceDraftCollection getPrices() |
|
25
|
|
|
* @method AttributeCollection getAttributes() |
|
26
|
|
|
* @method ImageCollection getImages() |
|
27
|
|
|
* @method ProductVariantDraft setImages(ImageCollection $images = null) |
|
28
|
|
|
* @method AssetDraftCollection getAssets() |
|
29
|
|
|
* @method ProductVariantDraft setAssets(AssetDraftCollection $assets = null) |
|
30
|
|
|
* @method string getKey() |
|
31
|
|
|
* @method ProductVariantDraft setKey(string $key = null) |
|
32
|
|
|
*/ |
|
33
|
|
|
class ProductVariantDraft extends JsonObject |
|
34
|
|
|
{ |
|
35
|
229 |
|
public function fieldDefinitions() |
|
36
|
|
|
{ |
|
37
|
|
|
return [ |
|
38
|
229 |
|
'sku' => [self::TYPE => 'string'], |
|
39
|
229 |
|
'prices' => [self::TYPE => PriceDraftCollection::class], |
|
40
|
229 |
|
'images' => [static::TYPE => ImageCollection::class], |
|
41
|
229 |
|
'attributes' => [self::TYPE => AttributeCollection::class], |
|
42
|
229 |
|
'assets' => [static::TYPE => AssetDraftCollection::class], |
|
43
|
229 |
|
'key' => [static::TYPE => 'string'], |
|
44
|
|
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param string $sku |
|
49
|
|
|
* @param Context|callable $context |
|
50
|
|
|
* @return ProductVariantDraft |
|
51
|
|
|
*/ |
|
52
|
7 |
|
public static function ofSku($sku, $context = null) |
|
53
|
|
|
{ |
|
54
|
7 |
|
return static::of($context)->setSku($sku); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param string $sku |
|
59
|
|
|
* @param PriceDraftCollection $prices |
|
60
|
|
|
* @param Context|callable $context |
|
61
|
|
|
* @return ProductVariantDraft |
|
62
|
|
|
*/ |
|
63
|
217 |
|
public static function ofSkuAndPrices($sku, PriceDraftCollection $prices, $context = null) |
|
64
|
|
|
{ |
|
65
|
217 |
|
return static::of($context)->setSku($sku)->setPrices($prices); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param PriceDraftCollection $prices |
|
70
|
|
|
* @param Context|callable $context |
|
71
|
|
|
* @return ProductVariantDraft |
|
72
|
|
|
*/ |
|
73
|
2 |
|
public static function ofPrices(PriceDraftCollection $prices, $context = null) |
|
74
|
|
|
{ |
|
75
|
2 |
|
return static::of($context)->setPrices($prices); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|