Skip to content

Commit bb3b2f0

Browse files
committed
ACP2E-412: Cant link configurable options with REST to product created on Backend
1 parent 60be1e7 commit bb3b2f0

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

app/code/Magento/Catalog/Model/Product/Type.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class Type implements OptionSourceInterface
2525
{
2626
const TYPE_SIMPLE = 'simple';
2727

28-
const TYPE_CONFIGURABLE = 'configurable';
29-
3028
const TYPE_BUNDLE = 'bundle';
3129

3230
const TYPE_VIRTUAL = 'virtual';

app/code/Magento/ConfigurableProduct/Model/OptionRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function save($sku, OptionInterface $option)
228228

229229
try {
230230
if ($product->getTypeId() === ProductType::TYPE_SIMPLE) {
231-
$product->setTypeId(ProductType::TYPE_CONFIGURABLE);
231+
$product->setTypeId(ConfigurableType::TYPE_CODE);
232232
$product->save();
233233
}
234234
$option->save();

dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/LinkManagementTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
namespace Magento\ConfigurableProduct\Api;
1010

1111
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
12+
use Magento\Eav\Api\AttributeRepositoryInterface;
1213
use Magento\Eav\Model\AttributeRepository;
1314
use Magento\Eav\Model\Entity\Attribute\Option;
1415
use Magento\Framework\Webapi\Rest\Request;
16+
use Magento\TestFramework\Helper\Bootstrap;
1517
use Magento\TestFramework\TestCase\WebapiAbstract;
1618

1719
/**
@@ -87,6 +89,52 @@ public function testAddChild(): void
8789
$this->assertTrue($res);
8890
}
8991

92+
/**
93+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
94+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php
95+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_simple_77.php
96+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/delete_association.php
97+
*
98+
* @return void
99+
*/
100+
public function testAddChildToConfigurableProdWithoutOption(): void
101+
{
102+
/** @var AttributeRepositoryInterface $attributeRepository */
103+
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
104+
105+
/** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
106+
$attribute = $attributeRepository->get('catalog_product', 'test_configurable');
107+
108+
$productSku = 'simple';
109+
$serviceInfo = [
110+
'rest' => [
111+
'resourcePath' => self::RESOURCE_PATH . '/' . $productSku . '/options',
112+
'httpMethod' => Request::HTTP_METHOD_POST
113+
],
114+
'soap' => [
115+
'service' => self::SERVICE_NAME,
116+
'serviceVersion' => self::SERVICE_VERSION,
117+
'operation' => self::SERVICE_NAME . 'Save'
118+
]
119+
];
120+
$option = [
121+
'attribute_id' => $attribute->getAttributeId(),
122+
'label' => 'Test',
123+
'values' => [
124+
[
125+
'value_index' => 1,
126+
]
127+
],
128+
];
129+
/** @var int $result */
130+
$result = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'option' => $option]);
131+
$this->assertGreaterThan(0, $result);
132+
133+
$childSku = 'simple_77';
134+
$res = $this->addChild($productSku, $childSku);
135+
$this->assertTrue($res);
136+
}
137+
90138
/**
91139
* Test the full flow of creating a configurable product and adding a child via REST
92140
*

0 commit comments

Comments
 (0)