commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ProductUpdateActionModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
21 {
22  public const DISCRIMINATOR_VALUE = '';
27  protected $action;
28 
33  private static $discriminatorClasses = [
34  'addAsset' => ProductAddAssetActionModel::class,
35  'addExternalImage' => ProductAddExternalImageActionModel::class,
36  'addPrice' => ProductAddPriceActionModel::class,
37  'addToCategory' => ProductAddToCategoryActionModel::class,
38  'addVariant' => ProductAddVariantActionModel::class,
39  'changeAssetName' => ProductChangeAssetNameActionModel::class,
40  'changeAssetOrder' => ProductChangeAssetOrderActionModel::class,
41  'changeMasterVariant' => ProductChangeMasterVariantActionModel::class,
42  'changeName' => ProductChangeNameActionModel::class,
43  'changePrice' => ProductChangePriceActionModel::class,
44  'changeSlug' => ProductChangeSlugActionModel::class,
45  'legacySetSku' => ProductLegacySetSkuActionModel::class,
46  'moveImageToPosition' => ProductMoveImageToPositionActionModel::class,
47  'publish' => ProductPublishActionModel::class,
48  'removeAsset' => ProductRemoveAssetActionModel::class,
49  'removeFromCategory' => ProductRemoveFromCategoryActionModel::class,
50  'removeImage' => ProductRemoveImageActionModel::class,
51  'removePrice' => ProductRemovePriceActionModel::class,
52  'removeVariant' => ProductRemoveVariantActionModel::class,
53  'revertStagedChanges' => ProductRevertStagedChangesActionModel::class,
54  'revertStagedVariantChanges' => ProductRevertStagedVariantChangesActionModel::class,
55  'setAssetCustomField' => ProductSetAssetCustomFieldActionModel::class,
56  'setAssetCustomType' => ProductSetAssetCustomTypeActionModel::class,
57  'setAssetDescription' => ProductSetAssetDescriptionActionModel::class,
58  'setAssetKey' => ProductSetAssetKeyActionModel::class,
59  'setAssetSources' => ProductSetAssetSourcesActionModel::class,
60  'setAssetTags' => ProductSetAssetTagsActionModel::class,
61  'setAttribute' => ProductSetAttributeActionModel::class,
62  'setAttributeInAllVariants' => ProductSetAttributeInAllVariantsActionModel::class,
63  'setCategoryOrderHint' => ProductSetCategoryOrderHintActionModel::class,
64  'setDescription' => ProductSetDescriptionActionModel::class,
65  'setDiscountedPrice' => ProductSetDiscountedPriceActionModel::class,
66  'setImageLabel' => ProductSetImageLabelActionModel::class,
67  'setKey' => ProductSetKeyActionModel::class,
68  'setMetaDescription' => ProductSetMetaDescriptionActionModel::class,
69  'setMetaKeywords' => ProductSetMetaKeywordsActionModel::class,
70  'setMetaTitle' => ProductSetMetaTitleActionModel::class,
71  'setPriceKey' => ProductSetPriceKeyActionModel::class,
72  'setPriceMode' => ProductSetPriceModeActionModel::class,
73  'setPrices' => ProductSetPricesActionModel::class,
74  'setProductPriceCustomField' => ProductSetProductPriceCustomFieldActionModel::class,
75  'setProductPriceCustomType' => ProductSetProductPriceCustomTypeActionModel::class,
76  'setProductVariantKey' => ProductSetProductVariantKeyActionModel::class,
77  'setSearchKeywords' => ProductSetSearchKeywordsActionModel::class,
78  'setSku' => ProductSetSkuActionModel::class,
79  'setTaxCategory' => ProductSetTaxCategoryActionModel::class,
80  'transitionState' => ProductTransitionStateActionModel::class,
81  'unpublish' => ProductUnpublishActionModel::class,
82  ];
83 
87  public function __construct(
88  ?string $action = null
89  ) {
90  $this->action = $action;
91  }
92 
97  public function getAction()
98  {
99  if (is_null($this->action)) {
101  $data = $this->raw(self::FIELD_ACTION);
102  if (is_null($data)) {
103  return null;
104  }
105  $this->action = (string) $data;
106  }
107 
108  return $this->action;
109  }
110 
111 
112 
113 
114 
119  public static function resolveDiscriminatorClass($value): string
120  {
122  if (is_object($value) && isset($value->$fieldName)) {
124  $discriminatorValue = $value->$fieldName;
125  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
126  return self::$discriminatorClasses[$discriminatorValue];
127  }
128  }
129  if (is_array($value) && isset($value[$fieldName])) {
131  $discriminatorValue = $value[$fieldName];
132  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
133  return self::$discriminatorClasses[$discriminatorValue];
134  }
135  }
136 
138  $type = ProductUpdateActionModel::class;
139  return $type;
140  }
141 }