diff --git a/src/Model/ProductType/ProductType.php b/src/Model/ProductType/ProductType.php index 3a600a2ca8..3269b75d33 100644 --- a/src/Model/ProductType/ProductType.php +++ b/src/Model/ProductType/ProductType.php @@ -25,6 +25,8 @@ * @method ProductType setDescription(string $description = null) * @method AttributeDefinitionCollection getAttributes() * @method ProductType setAttributes(AttributeDefinitionCollection $attributes = null) + * @method string getKey() + * @method ProductType setKey(string $key = null) */ class ProductType extends Resource { @@ -44,6 +46,7 @@ public function fieldDefinitions() static::TYPE => '\DateTime', static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator' ], + 'key' => [static::TYPE => 'string'], 'name' => [static::TYPE => 'string'], 'description' => [static::TYPE => 'string'], 'attributes' => [static::TYPE => '\Commercetools\Core\Model\ProductType\AttributeDefinitionCollection'] diff --git a/src/Model/ProductType/ProductTypeDraft.php b/src/Model/ProductType/ProductTypeDraft.php index 853dfd3d79..f326b7da36 100644 --- a/src/Model/ProductType/ProductTypeDraft.php +++ b/src/Model/ProductType/ProductTypeDraft.php @@ -17,6 +17,8 @@ * @method ProductTypeDraft setDescription(string $description = null) * @method AttributeDefinitionCollection getAttributes() * @method ProductTypeDraft setAttributes(AttributeDefinitionCollection $attributes = null) + * @method string getKey() + * @method ProductTypeDraft setKey(string $key = null) */ class ProductTypeDraft extends JsonObject { @@ -24,6 +26,7 @@ public function fieldDefinitions() { return [ 'name' => [static::TYPE => 'string'], + 'key' => [static::TYPE => 'string'], 'description' => [static::TYPE => 'string'], 'attributes' => [static::TYPE => '\Commercetools\Core\Model\ProductType\AttributeDefinitionCollection'], ]; diff --git a/src/Request/ProductTypes/Command/ProductTypeSetKeyAction.php b/src/Request/ProductTypes/Command/ProductTypeSetKeyAction.php new file mode 100644 index 0000000000..bf14ef68ce --- /dev/null +++ b/src/Request/ProductTypes/Command/ProductTypeSetKeyAction.php @@ -0,0 +1,48 @@ + + */ + +namespace Commercetools\Core\Request\ProductTypes\Command; + +use Commercetools\Core\Model\Common\Context; +use Commercetools\Core\Request\AbstractAction; + +/** + * @package Commercetools\Core\Request\ProductTypes\Command + * @link https://dev.commercetools.com/http-api-projects-productTypes.html#set-key + * @method string getAction() + * @method ProductTypeSetKeyAction setAction(string $action = null) + * @method string getKey() + * @method ProductTypeSetKeyAction setKey(string $key = null) + */ +class ProductTypeSetKeyAction extends AbstractAction +{ + public function fieldDefinitions() + { + return [ + 'action' => [static::TYPE => 'string'], + 'key' => [static::TYPE => 'string'] + ]; + } + + /** + * @param array $data + * @param Context|callable $context + */ + public function __construct(array $data = [], $context = null) + { + parent::__construct($data, $context); + $this->setAction('setKey'); + } + + /** + * @param string $name + * @param Context|callable $context + * @return ProductTypeSetKeyAction + */ + public static function ofKey($key, $context = null) + { + return static::of($context)->setKey($key); + } +} diff --git a/tests/fixtures/models.yaml b/tests/fixtures/models.yaml index f34e8c1d29..b863a4ab77 100644 --- a/tests/fixtures/models.yaml +++ b/tests/fixtures/models.yaml @@ -749,6 +749,7 @@ productType: - version - createdAt - lastModifiedAt + - key - name - description - attributes @@ -757,6 +758,7 @@ productTypeDraft: domain: productType model: ProductTypeDraft fields: + - key - name - description - attributes