|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Commercetools\Core\Builder\Update; |
|
4
|
|
|
|
|
5
|
|
|
use Commercetools\Core\Error\InvalidArgumentException; |
|
6
|
|
|
use Commercetools\Core\Request\AbstractAction; |
|
7
|
|
|
use Commercetools\Core\Request\Products\Command\ProductAddAssetAction; |
|
8
|
|
|
use Commercetools\Core\Request\Products\Command\ProductAddExternalImageAction; |
|
9
|
|
|
use Commercetools\Core\Request\Products\Command\ProductAddPriceAction; |
|
10
|
|
|
use Commercetools\Core\Request\Products\Command\ProductAddToCategoryAction; |
|
11
|
|
|
use Commercetools\Core\Request\Products\Command\ProductAddVariantAction; |
|
12
|
|
|
use Commercetools\Core\Request\Products\Command\ProductChangeAssetNameAction; |
|
13
|
|
|
use Commercetools\Core\Request\Products\Command\ProductChangeAssetOrderAction; |
|
14
|
|
|
use Commercetools\Core\Request\Products\Command\ProductChangeMasterVariantAction; |
|
15
|
|
|
use Commercetools\Core\Request\Products\Command\ProductChangeNameAction; |
|
16
|
|
|
use Commercetools\Core\Request\Products\Command\ProductChangePriceAction; |
|
17
|
|
|
use Commercetools\Core\Request\Products\Command\ProductChangeSlugAction; |
|
18
|
|
|
use Commercetools\Core\Request\Products\Command\ProductMoveImageToPositionAction; |
|
19
|
|
|
use Commercetools\Core\Request\Products\Command\ProductPublishAction; |
|
20
|
|
|
use Commercetools\Core\Request\Products\Command\ProductRemoveAssetAction; |
|
21
|
|
|
use Commercetools\Core\Request\Products\Command\ProductRemoveFromCategoryAction; |
|
22
|
|
|
use Commercetools\Core\Request\Products\Command\ProductRemoveImageAction; |
|
23
|
|
|
use Commercetools\Core\Request\Products\Command\ProductRemovePriceAction; |
|
24
|
|
|
use Commercetools\Core\Request\Products\Command\ProductRemoveVariantAction; |
|
25
|
|
|
use Commercetools\Core\Request\Products\Command\ProductRevertStagedChangesAction; |
|
26
|
|
|
use Commercetools\Core\Request\Products\Command\ProductRevertStagedVariantChangesAction; |
|
27
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAssetCustomFieldAction; |
|
28
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAssetCustomTypeAction; |
|
29
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAssetDescriptionAction; |
|
30
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAssetKeyAction; |
|
31
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAssetSourcesAction; |
|
32
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAssetTagsAction; |
|
33
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAttributeAction; |
|
34
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetAttributeInAllVariantsAction; |
|
35
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetCategoryOrderHintAction; |
|
36
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetDescriptionAction; |
|
37
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetDiscountedPriceAction; |
|
38
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetKeyAction; |
|
39
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetMetaDescriptionAction; |
|
40
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetMetaKeywordsAction; |
|
41
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetMetaTitleAction; |
|
42
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetPriceCustomFieldAction; |
|
43
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetPriceCustomTypeAction; |
|
44
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetPricesAction; |
|
45
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetProductVariantKeyAction; |
|
46
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetSearchKeywordsAction; |
|
47
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetSkuAction; |
|
48
|
|
|
use Commercetools\Core\Request\Products\Command\ProductSetTaxCategoryAction; |
|
49
|
|
|
use Commercetools\Core\Request\Products\Command\ProductTransitionStateAction; |
|
50
|
|
|
use Commercetools\Core\Request\Products\Command\ProductUnpublishAction; |
|
51
|
|
|
|
|
52
|
|
|
class ProductsActionBuilder |
|
53
|
|
|
{ |
|
54
|
|
|
private $actions = []; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#add-asset |
|
58
|
|
|
* @param ProductAddAssetAction|callable $action |
|
59
|
|
|
* @return $this |
|
60
|
|
|
*/ |
|
61
|
1 |
|
public function addAsset($action = null) |
|
62
|
|
|
{ |
|
63
|
1 |
|
$this->addAction($this->resolveAction(ProductAddAssetAction::class, $action)); |
|
64
|
1 |
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#add-external-image |
|
69
|
|
|
* @param ProductAddExternalImageAction|callable $action |
|
70
|
|
|
* @return $this |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function addExternalImage($action = null) |
|
73
|
|
|
{ |
|
74
|
1 |
|
$this->addAction($this->resolveAction(ProductAddExternalImageAction::class, $action)); |
|
75
|
1 |
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#add-price |
|
80
|
|
|
* @param ProductAddPriceAction|callable $action |
|
81
|
|
|
* @return $this |
|
82
|
|
|
*/ |
|
83
|
1 |
|
public function addPrice($action = null) |
|
84
|
|
|
{ |
|
85
|
1 |
|
$this->addAction($this->resolveAction(ProductAddPriceAction::class, $action)); |
|
86
|
1 |
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#add-to-category |
|
91
|
|
|
* @param ProductAddToCategoryAction|callable $action |
|
92
|
|
|
* @return $this |
|
93
|
|
|
*/ |
|
94
|
1 |
|
public function addToCategory($action = null) |
|
95
|
|
|
{ |
|
96
|
1 |
|
$this->addAction($this->resolveAction(ProductAddToCategoryAction::class, $action)); |
|
97
|
1 |
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#add-productvariant |
|
102
|
|
|
* @param ProductAddVariantAction|callable $action |
|
103
|
|
|
* @return $this |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function addVariant($action = null) |
|
106
|
|
|
{ |
|
107
|
1 |
|
$this->addAction($this->resolveAction(ProductAddVariantAction::class, $action)); |
|
108
|
1 |
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#change-asset-name |
|
113
|
|
|
* @param ProductChangeAssetNameAction|callable $action |
|
114
|
|
|
* @return $this |
|
115
|
|
|
*/ |
|
116
|
1 |
|
public function changeAssetName($action = null) |
|
117
|
|
|
{ |
|
118
|
1 |
|
$this->addAction($this->resolveAction(ProductChangeAssetNameAction::class, $action)); |
|
119
|
1 |
|
return $this; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#change-asset-order |
|
124
|
|
|
* @param ProductChangeAssetOrderAction|callable $action |
|
125
|
|
|
* @return $this |
|
126
|
|
|
*/ |
|
127
|
1 |
|
public function changeAssetOrder($action = null) |
|
128
|
|
|
{ |
|
129
|
1 |
|
$this->addAction($this->resolveAction(ProductChangeAssetOrderAction::class, $action)); |
|
130
|
1 |
|
return $this; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#change-master-variant |
|
135
|
|
|
* @param ProductChangeMasterVariantAction|callable $action |
|
136
|
|
|
* @return $this |
|
137
|
|
|
*/ |
|
138
|
1 |
|
public function changeMasterVariant($action = null) |
|
139
|
|
|
{ |
|
140
|
1 |
|
$this->addAction($this->resolveAction(ProductChangeMasterVariantAction::class, $action)); |
|
141
|
1 |
|
return $this; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#change-name |
|
146
|
|
|
* @param ProductChangeNameAction|callable $action |
|
147
|
|
|
* @return $this |
|
148
|
|
|
*/ |
|
149
|
1 |
|
public function changeName($action = null) |
|
150
|
|
|
{ |
|
151
|
1 |
|
$this->addAction($this->resolveAction(ProductChangeNameAction::class, $action)); |
|
152
|
1 |
|
return $this; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#change-price |
|
157
|
|
|
* @param ProductChangePriceAction|callable $action |
|
158
|
|
|
* @return $this |
|
159
|
|
|
*/ |
|
160
|
1 |
|
public function changePrice($action = null) |
|
161
|
|
|
{ |
|
162
|
1 |
|
$this->addAction($this->resolveAction(ProductChangePriceAction::class, $action)); |
|
163
|
1 |
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#change-slug |
|
168
|
|
|
* @param ProductChangeSlugAction|callable $action |
|
169
|
|
|
* @return $this |
|
170
|
|
|
*/ |
|
171
|
1 |
|
public function changeSlug($action = null) |
|
172
|
|
|
{ |
|
173
|
1 |
|
$this->addAction($this->resolveAction(ProductChangeSlugAction::class, $action)); |
|
174
|
1 |
|
return $this; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#move-image-to-position |
|
179
|
|
|
* @param ProductMoveImageToPositionAction|callable $action |
|
180
|
|
|
* @return $this |
|
181
|
|
|
*/ |
|
182
|
1 |
|
public function moveImageToPosition($action = null) |
|
183
|
|
|
{ |
|
184
|
1 |
|
$this->addAction($this->resolveAction(ProductMoveImageToPositionAction::class, $action)); |
|
185
|
1 |
|
return $this; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#publish |
|
190
|
|
|
* @param ProductPublishAction|callable $action |
|
191
|
|
|
* @return $this |
|
192
|
|
|
*/ |
|
193
|
1 |
|
public function publish($action = null) |
|
194
|
|
|
{ |
|
195
|
1 |
|
$this->addAction($this->resolveAction(ProductPublishAction::class, $action)); |
|
196
|
1 |
|
return $this; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#remove-asset |
|
201
|
|
|
* @param ProductRemoveAssetAction|callable $action |
|
202
|
|
|
* @return $this |
|
203
|
|
|
*/ |
|
204
|
1 |
|
public function removeAsset($action = null) |
|
205
|
|
|
{ |
|
206
|
1 |
|
$this->addAction($this->resolveAction(ProductRemoveAssetAction::class, $action)); |
|
207
|
1 |
|
return $this; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#remove-from-category |
|
212
|
|
|
* @param ProductRemoveFromCategoryAction|callable $action |
|
213
|
|
|
* @return $this |
|
214
|
|
|
*/ |
|
215
|
1 |
|
public function removeFromCategory($action = null) |
|
216
|
|
|
{ |
|
217
|
1 |
|
$this->addAction($this->resolveAction(ProductRemoveFromCategoryAction::class, $action)); |
|
218
|
1 |
|
return $this; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#remove-image |
|
223
|
|
|
* @param ProductRemoveImageAction|callable $action |
|
224
|
|
|
* @return $this |
|
225
|
|
|
*/ |
|
226
|
1 |
|
public function removeImage($action = null) |
|
227
|
|
|
{ |
|
228
|
1 |
|
$this->addAction($this->resolveAction(ProductRemoveImageAction::class, $action)); |
|
229
|
1 |
|
return $this; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
/** |
|
233
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#remove-price |
|
234
|
|
|
* @param ProductRemovePriceAction|callable $action |
|
235
|
|
|
* @return $this |
|
236
|
|
|
*/ |
|
237
|
1 |
|
public function removePrice($action = null) |
|
238
|
|
|
{ |
|
239
|
1 |
|
$this->addAction($this->resolveAction(ProductRemovePriceAction::class, $action)); |
|
240
|
1 |
|
return $this; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#remove-productvariant |
|
245
|
|
|
* @param ProductRemoveVariantAction|callable $action |
|
246
|
|
|
* @return $this |
|
247
|
|
|
*/ |
|
248
|
1 |
|
public function removeVariant($action = null) |
|
249
|
|
|
{ |
|
250
|
1 |
|
$this->addAction($this->resolveAction(ProductRemoveVariantAction::class, $action)); |
|
251
|
1 |
|
return $this; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#revert-staged-changes |
|
256
|
|
|
* @param ProductRevertStagedChangesAction|callable $action |
|
257
|
|
|
* @return $this |
|
258
|
|
|
*/ |
|
259
|
1 |
|
public function revertStagedChanges($action = null) |
|
260
|
|
|
{ |
|
261
|
1 |
|
$this->addAction($this->resolveAction(ProductRevertStagedChangesAction::class, $action)); |
|
262
|
1 |
|
return $this; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#revert-staged-variant-changes |
|
267
|
|
|
* @param ProductRevertStagedVariantChangesAction|callable $action |
|
268
|
|
|
* @return $this |
|
269
|
|
|
*/ |
|
270
|
1 |
|
public function revertStagedVariantChanges($action = null) |
|
271
|
|
|
{ |
|
272
|
1 |
|
$this->addAction($this->resolveAction(ProductRevertStagedVariantChangesAction::class, $action)); |
|
273
|
1 |
|
return $this; |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-asset-customfield |
|
278
|
|
|
* @param ProductSetAssetCustomFieldAction|callable $action |
|
279
|
|
|
* @return $this |
|
280
|
|
|
*/ |
|
281
|
1 |
|
public function setAssetCustomField($action = null) |
|
282
|
|
|
{ |
|
283
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAssetCustomFieldAction::class, $action)); |
|
284
|
1 |
|
return $this; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
/** |
|
288
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-asset-custom-type |
|
289
|
|
|
* @param ProductSetAssetCustomTypeAction|callable $action |
|
290
|
|
|
* @return $this |
|
291
|
|
|
*/ |
|
292
|
1 |
|
public function setAssetCustomType($action = null) |
|
293
|
|
|
{ |
|
294
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAssetCustomTypeAction::class, $action)); |
|
295
|
1 |
|
return $this; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-asset-description |
|
300
|
|
|
* @param ProductSetAssetDescriptionAction|callable $action |
|
301
|
|
|
* @return $this |
|
302
|
|
|
*/ |
|
303
|
1 |
|
public function setAssetDescription($action = null) |
|
304
|
|
|
{ |
|
305
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAssetDescriptionAction::class, $action)); |
|
306
|
1 |
|
return $this; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-asset-key |
|
311
|
|
|
* @param ProductSetAssetKeyAction|callable $action |
|
312
|
|
|
* @return $this |
|
313
|
|
|
*/ |
|
314
|
1 |
|
public function setAssetKey($action = null) |
|
315
|
|
|
{ |
|
316
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAssetKeyAction::class, $action)); |
|
317
|
1 |
|
return $this; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-asset-tags |
|
322
|
|
|
* @param ProductSetAssetSourcesAction|callable $action |
|
323
|
|
|
* @return $this |
|
324
|
|
|
*/ |
|
325
|
1 |
|
public function setAssetSources($action = null) |
|
326
|
|
|
{ |
|
327
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAssetSourcesAction::class, $action)); |
|
328
|
1 |
|
return $this; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-asset-tags |
|
333
|
|
|
* @param ProductSetAssetTagsAction|callable $action |
|
334
|
|
|
* @return $this |
|
335
|
|
|
*/ |
|
336
|
1 |
|
public function setAssetTags($action = null) |
|
337
|
|
|
{ |
|
338
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAssetTagsAction::class, $action)); |
|
339
|
1 |
|
return $this; |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-attribute |
|
344
|
|
|
* @param ProductSetAttributeAction|callable $action |
|
345
|
|
|
* @return $this |
|
346
|
|
|
*/ |
|
347
|
1 |
|
public function setAttribute($action = null) |
|
348
|
|
|
{ |
|
349
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAttributeAction::class, $action)); |
|
350
|
1 |
|
return $this; |
|
351
|
|
|
} |
|
352
|
|
|
|
|
353
|
|
|
/** |
|
354
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-attribute-in-all-variants |
|
355
|
|
|
* @param ProductSetAttributeInAllVariantsAction|callable $action |
|
356
|
|
|
* @return $this |
|
357
|
|
|
*/ |
|
358
|
1 |
|
public function setAttributeInAllVariants($action = null) |
|
359
|
|
|
{ |
|
360
|
1 |
|
$this->addAction($this->resolveAction(ProductSetAttributeInAllVariantsAction::class, $action)); |
|
361
|
1 |
|
return $this; |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-category-order-hint |
|
366
|
|
|
* @param ProductSetCategoryOrderHintAction|callable $action |
|
367
|
|
|
* @return $this |
|
368
|
|
|
*/ |
|
369
|
1 |
|
public function setCategoryOrderHint($action = null) |
|
370
|
|
|
{ |
|
371
|
1 |
|
$this->addAction($this->resolveAction(ProductSetCategoryOrderHintAction::class, $action)); |
|
372
|
1 |
|
return $this; |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
/** |
|
376
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-description |
|
377
|
|
|
* @param ProductSetDescriptionAction|callable $action |
|
378
|
|
|
* @return $this |
|
379
|
|
|
*/ |
|
380
|
1 |
|
public function setDescription($action = null) |
|
381
|
|
|
{ |
|
382
|
1 |
|
$this->addAction($this->resolveAction(ProductSetDescriptionAction::class, $action)); |
|
383
|
1 |
|
return $this; |
|
384
|
|
|
} |
|
385
|
|
|
|
|
386
|
|
|
/** |
|
387
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-discounted-price |
|
388
|
|
|
* @param ProductSetDiscountedPriceAction|callable $action |
|
389
|
|
|
* @return $this |
|
390
|
|
|
*/ |
|
391
|
1 |
|
public function setDiscountedPrice($action = null) |
|
392
|
|
|
{ |
|
393
|
1 |
|
$this->addAction($this->resolveAction(ProductSetDiscountedPriceAction::class, $action)); |
|
394
|
1 |
|
return $this; |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
/** |
|
398
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-key |
|
399
|
|
|
* @param ProductSetKeyAction|callable $action |
|
400
|
|
|
* @return $this |
|
401
|
|
|
*/ |
|
402
|
1 |
|
public function setKey($action = null) |
|
403
|
|
|
{ |
|
404
|
1 |
|
$this->addAction($this->resolveAction(ProductSetKeyAction::class, $action)); |
|
405
|
1 |
|
return $this; |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
/** |
|
409
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-meta-description |
|
410
|
|
|
* @param ProductSetMetaDescriptionAction|callable $action |
|
411
|
|
|
* @return $this |
|
412
|
|
|
*/ |
|
413
|
1 |
|
public function setMetaDescription($action = null) |
|
414
|
|
|
{ |
|
415
|
1 |
|
$this->addAction($this->resolveAction(ProductSetMetaDescriptionAction::class, $action)); |
|
416
|
1 |
|
return $this; |
|
417
|
|
|
} |
|
418
|
|
|
|
|
419
|
|
|
/** |
|
420
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-meta-keywords |
|
421
|
|
|
* @param ProductSetMetaKeywordsAction|callable $action |
|
422
|
|
|
* @return $this |
|
423
|
|
|
*/ |
|
424
|
1 |
|
public function setMetaKeywords($action = null) |
|
425
|
|
|
{ |
|
426
|
1 |
|
$this->addAction($this->resolveAction(ProductSetMetaKeywordsAction::class, $action)); |
|
427
|
1 |
|
return $this; |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
/** |
|
431
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-meta-title |
|
432
|
|
|
* @param ProductSetMetaTitleAction|callable $action |
|
433
|
|
|
* @return $this |
|
434
|
|
|
*/ |
|
435
|
1 |
|
public function setMetaTitle($action = null) |
|
436
|
|
|
{ |
|
437
|
1 |
|
$this->addAction($this->resolveAction(ProductSetMetaTitleAction::class, $action)); |
|
438
|
1 |
|
return $this; |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
|
|
/** |
|
442
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-price-customfield |
|
443
|
|
|
* @param ProductSetPriceCustomFieldAction|callable $action |
|
444
|
|
|
* @return $this |
|
445
|
|
|
*/ |
|
446
|
1 |
|
public function setProductPriceCustomField($action = null) |
|
447
|
|
|
{ |
|
448
|
1 |
|
$this->addAction($this->resolveAction(ProductSetPriceCustomFieldAction::class, $action)); |
|
449
|
1 |
|
return $this; |
|
450
|
|
|
} |
|
451
|
|
|
|
|
452
|
|
|
/** |
|
453
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-price-custom-type |
|
454
|
|
|
* @param ProductSetPriceCustomTypeAction|callable $action |
|
455
|
|
|
* @return $this |
|
456
|
|
|
*/ |
|
457
|
1 |
|
public function setProductPriceCustomType($action = null) |
|
458
|
|
|
{ |
|
459
|
1 |
|
$this->addAction($this->resolveAction(ProductSetPriceCustomTypeAction::class, $action)); |
|
460
|
1 |
|
return $this; |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
/** |
|
464
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-prices |
|
465
|
|
|
* @param ProductSetPricesAction|callable $action |
|
466
|
|
|
* @return $this |
|
467
|
|
|
*/ |
|
468
|
1 |
|
public function setPrices($action = null) |
|
469
|
|
|
{ |
|
470
|
1 |
|
$this->addAction($this->resolveAction(ProductSetPricesAction::class, $action)); |
|
471
|
1 |
|
return $this; |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
/** |
|
475
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-productvariant-key |
|
476
|
|
|
* @param ProductSetProductVariantKeyAction|callable $action |
|
477
|
|
|
* @return $this |
|
478
|
|
|
*/ |
|
479
|
1 |
|
public function setProductVariantKey($action = null) |
|
480
|
|
|
{ |
|
481
|
1 |
|
$this->addAction($this->resolveAction(ProductSetProductVariantKeyAction::class, $action)); |
|
482
|
1 |
|
return $this; |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-searchkeywords |
|
487
|
|
|
* @param ProductSetSearchKeywordsAction|callable $action |
|
488
|
|
|
* @return $this |
|
489
|
|
|
*/ |
|
490
|
1 |
|
public function setSearchKeywords($action = null) |
|
491
|
|
|
{ |
|
492
|
1 |
|
$this->addAction($this->resolveAction(ProductSetSearchKeywordsAction::class, $action)); |
|
493
|
1 |
|
return $this; |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
/** |
|
497
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-sku |
|
498
|
|
|
* @param ProductSetSkuAction|callable $action |
|
499
|
|
|
* @return $this |
|
500
|
|
|
*/ |
|
501
|
1 |
|
public function setSku($action = null) |
|
502
|
|
|
{ |
|
503
|
1 |
|
$this->addAction($this->resolveAction(ProductSetSkuAction::class, $action)); |
|
504
|
1 |
|
return $this; |
|
505
|
|
|
} |
|
506
|
|
|
|
|
507
|
|
|
/** |
|
508
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#set-taxcategory |
|
509
|
|
|
* @param ProductSetTaxCategoryAction|callable $action |
|
510
|
|
|
* @return $this |
|
511
|
|
|
*/ |
|
512
|
1 |
|
public function setTaxCategory($action = null) |
|
513
|
|
|
{ |
|
514
|
1 |
|
$this->addAction($this->resolveAction(ProductSetTaxCategoryAction::class, $action)); |
|
515
|
1 |
|
return $this; |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
/** |
|
519
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#transition-state |
|
520
|
|
|
* @param ProductTransitionStateAction|callable $action |
|
521
|
|
|
* @return $this |
|
522
|
|
|
*/ |
|
523
|
1 |
|
public function transitionState($action = null) |
|
524
|
|
|
{ |
|
525
|
1 |
|
$this->addAction($this->resolveAction(ProductTransitionStateAction::class, $action)); |
|
526
|
1 |
|
return $this; |
|
527
|
|
|
} |
|
528
|
|
|
|
|
529
|
|
|
/** |
|
530
|
|
|
* @link https://docs.commercetools.com/http-api-projects-products.html#unpublish |
|
531
|
|
|
* @param ProductUnpublishAction|callable $action |
|
532
|
|
|
* @return $this |
|
533
|
|
|
*/ |
|
534
|
1 |
|
public function unpublish($action = null) |
|
535
|
|
|
{ |
|
536
|
1 |
|
$this->addAction($this->resolveAction(ProductUnpublishAction::class, $action)); |
|
537
|
1 |
|
return $this; |
|
538
|
|
|
} |
|
539
|
|
|
|
|
540
|
|
|
/** |
|
541
|
|
|
* @return ProductsActionBuilder |
|
542
|
|
|
*/ |
|
543
|
|
|
public static function of() |
|
544
|
|
|
{ |
|
545
|
|
|
return new self(); |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
/** |
|
549
|
|
|
* @param $class |
|
550
|
|
|
* @param $action |
|
551
|
|
|
* @return AbstractAction |
|
552
|
|
|
* @throws InvalidArgumentException |
|
553
|
|
|
*/ |
|
554
|
44 |
|
private function resolveAction($class, $action = null) |
|
555
|
|
|
{ |
|
556
|
44 |
|
if (is_null($action) || is_callable($action)) { |
|
557
|
44 |
|
$callback = $action; |
|
558
|
44 |
|
$emptyAction = $class::of(); |
|
559
|
44 |
|
$action = $this->callback($emptyAction, $callback); |
|
560
|
|
|
} |
|
561
|
44 |
|
if ($action instanceof $class) { |
|
562
|
44 |
|
return $action; |
|
563
|
|
|
} |
|
564
|
|
|
throw new InvalidArgumentException( |
|
565
|
|
|
sprintf('Expected method to be called with or callable to return %s', $class) |
|
566
|
|
|
); |
|
567
|
|
|
} |
|
568
|
|
|
|
|
569
|
|
|
/** |
|
570
|
|
|
* @param $action |
|
571
|
|
|
* @param callable $callback |
|
572
|
|
|
* @return AbstractAction |
|
573
|
|
|
*/ |
|
574
|
44 |
|
private function callback($action, callable $callback = null) |
|
575
|
|
|
{ |
|
576
|
44 |
|
if (!is_null($callback)) { |
|
577
|
|
|
$action = $callback($action); |
|
578
|
|
|
} |
|
579
|
44 |
|
return $action; |
|
580
|
|
|
} |
|
581
|
|
|
|
|
582
|
|
|
/** |
|
583
|
|
|
* @param AbstractAction $action |
|
584
|
|
|
* @return $this; |
|
585
|
|
|
*/ |
|
586
|
44 |
|
public function addAction(AbstractAction $action) |
|
587
|
|
|
{ |
|
588
|
44 |
|
$this->actions[] = $action; |
|
589
|
44 |
|
return $this; |
|
590
|
|
|
} |
|
591
|
|
|
|
|
592
|
|
|
/** |
|
593
|
|
|
* @return array |
|
594
|
|
|
*/ |
|
595
|
44 |
|
public function getActions() |
|
596
|
|
|
{ |
|
597
|
44 |
|
return $this->actions; |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
|
|
601
|
|
|
/** |
|
602
|
|
|
* @param array $actions |
|
603
|
|
|
* @return $this |
|
604
|
|
|
*/ |
|
605
|
|
|
public function setActions(array $actions) |
|
606
|
|
|
{ |
|
607
|
|
|
$this->actions = $actions; |
|
608
|
|
|
return $this; |
|
609
|
|
|
} |
|
610
|
|
|
} |
|
611
|
|
|
|