Skip to content

Commit 34f6307

Browse files
committed
MC-32996: Product Attribute Option Label update Magento 2.3.4 REST API
1 parent 134ef81 commit 34f6307

File tree

8 files changed

+710
-304
lines changed

8 files changed

+710
-304
lines changed

app/code/Magento/Catalog/Api/ProductAttributeOptionManagementInterface.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ public function getItems($attributeCode);
3333
*/
3434
public function add($attributeCode, $option);
3535

36+
/**
37+
* Update attribute option
38+
*
39+
* @param string $attributeCode
40+
* @param int $optionId
41+
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
42+
* @return bool
43+
* @throws \Magento\Framework\Exception\StateException
44+
* @throws \Magento\Framework\Exception\NoSuchEntityException
45+
* @throws \Magento\Framework\Exception\InputException
46+
*/
47+
public function update($attributeCode, $optionId, $option);
48+
3649
/**
3750
* Delete option from attribute
3851
*

app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,26 @@
66
*/
77
namespace Magento\Catalog\Model\Product\Attribute;
88

9+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
10+
use Magento\Catalog\Api\ProductAttributeOptionManagementInterface;
11+
use Magento\Eav\Api\AttributeOptionManagementInterface;
912
use Magento\Framework\Exception\InputException;
1013

1114
/**
1215
* Option management model for product attribute.
1316
*/
14-
class OptionManagement implements \Magento\Catalog\Api\ProductAttributeOptionManagementInterface
17+
class OptionManagement implements ProductAttributeOptionManagementInterface
1518
{
1619
/**
17-
* @var \Magento\Eav\Api\AttributeOptionManagementInterface
20+
* @var AttributeOptionManagementInterface
1821
*/
1922
protected $eavOptionManagement;
2023

2124
/**
22-
* @param \Magento\Eav\Api\AttributeOptionManagementInterface $eavOptionManagement
25+
* @param AttributeOptionManagementInterface $eavOptionManagement
2326
*/
2427
public function __construct(
25-
\Magento\Eav\Api\AttributeOptionManagementInterface $eavOptionManagement
28+
AttributeOptionManagementInterface $eavOptionManagement
2629
) {
2730
$this->eavOptionManagement = $eavOptionManagement;
2831
}
@@ -33,7 +36,7 @@ public function __construct(
3336
public function getItems($attributeCode)
3437
{
3538
return $this->eavOptionManagement->getItems(
36-
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
39+
ProductAttributeInterface::ENTITY_TYPE_CODE,
3740
$attributeCode
3841
);
3942
}
@@ -44,12 +47,25 @@ public function getItems($attributeCode)
4447
public function add($attributeCode, $option)
4548
{
4649
return $this->eavOptionManagement->add(
47-
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
50+
ProductAttributeInterface::ENTITY_TYPE_CODE,
4851
$attributeCode,
4952
$option
5053
);
5154
}
5255

56+
/**
57+
* @inheritdoc
58+
*/
59+
public function update($attributeCode, $optionId, $option)
60+
{
61+
return $this->eavOptionManagement->update(
62+
ProductAttributeInterface::ENTITY_TYPE_CODE,
63+
$attributeCode,
64+
$optionId,
65+
$option
66+
);
67+
}
68+
5369
/**
5470
* @inheritdoc
5571
*/
@@ -60,7 +76,7 @@ public function delete($attributeCode, $optionId)
6076
}
6177

6278
return $this->eavOptionManagement->delete(
63-
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
79+
ProductAttributeInterface::ENTITY_TYPE_CODE,
6480
$attributeCode,
6581
$optionId
6682
);

app/code/Magento/Catalog/etc/webapi.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@
183183
<resource ref="Magento_Catalog::attributes_attributes" />
184184
</resources>
185185
</route>
186+
<route url="/V1/products/attributes/:attributeCode/options/:optionId" method="PUT">
187+
<service class="Magento\Catalog\Api\ProductAttributeOptionManagementInterface" method="update" />
188+
<resources>
189+
<resource ref="Magento_Catalog::attributes_attributes" />
190+
</resources>
191+
</route>
186192
<route url="/V1/products/attributes/:attributeCode/options/:optionId" method="DELETE">
187193
<service class="Magento\Catalog\Api\ProductAttributeOptionManagementInterface" method="delete" />
188194
<resources>

app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,29 @@ interface AttributeOptionManagementInterface
1515
/**
1616
* Add option to attribute
1717
*
18-
* @param string $attributeCode
1918
* @param int $entityType
19+
* @param string $attributeCode
2020
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
2121
* @throws \Magento\Framework\Exception\StateException
2222
* @throws \Magento\Framework\Exception\InputException
2323
* @return string
2424
*/
2525
public function add($entityType, $attributeCode, $option);
2626

27+
/**
28+
* Update attribute option
29+
*
30+
* @param string $entityType
31+
* @param string $attributeCode
32+
* @param int $optionId
33+
* @param \Magento\Eav\Api\Data\AttributeOptionInterface $option
34+
* @return bool
35+
* @throws \Magento\Framework\Exception\StateException
36+
* @throws \Magento\Framework\Exception\InputException
37+
* @throws \Magento\Framework\Exception\NoSuchEntityException
38+
*/
39+
public function update($entityType, $attributeCode, $optionId, $option);
40+
2741
/**
2842
* Delete option from attribute
2943
*

0 commit comments

Comments
 (0)