Skip to content

Commit 0917099

Browse files
committed
Merge remote-tracking branch 'l3/ACP2E-412' into PR_L3_18_04_2022
2 parents df62fbd + 878108c commit 0917099

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ public function save($sku, OptionInterface $option)
227227
}
228228

229229
try {
230+
if ($product->getTypeId() === ProductType::TYPE_SIMPLE) {
231+
$product->setTypeId(ConfigurableType::TYPE_CODE);
232+
$product->save();
233+
}
230234
$option->save();
231235
} catch (\Exception $e) {
232236
throw new CouldNotSaveException(__('An error occurred while saving the option. Please try to save again.'));

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
namespace Magento\ConfigurableProduct\Api;
1010

1111
use Magento\TestFramework\Helper\Bootstrap;
12+
use Magento\Catalog\Model\ProductRepository;
1213
use Magento\Eav\Api\AttributeRepositoryInterface;
1314

1415
/**
1516
* Class OptionRepositoryTest for testing ConfigurableProductoption integration
1617
*/
1718
class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstract
1819
{
19-
const SERVICE_NAME = 'configurableProductOptionRepositoryV1';
20-
const SERVICE_VERSION = 'V1';
21-
const RESOURCE_PATH = '/V1/configurable-products';
20+
public const SERVICE_NAME = 'configurableProductOptionRepositoryV1';
21+
public const SERVICE_VERSION = 'V1';
22+
public const RESOURCE_PATH = '/V1/configurable-products';
2223

2324
/**
2425
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
@@ -166,6 +167,9 @@ public function testAdd(): void
166167
$attribute = $attributeRepository->get('catalog_product', 'test_configurable');
167168

168169
$productSku = 'simple';
170+
$productRepository = Bootstrap::getObjectManager()->create(ProductRepository::class);
171+
$product = $productRepository->get($productSku);
172+
$this->assertEquals('simple', $product->getTypeId());
169173
$serviceInfo = [
170174
'rest' => [
171175
'resourcePath' => self::RESOURCE_PATH . '/' . $productSku . '/options',
@@ -189,6 +193,9 @@ public function testAdd(): void
189193
/** @var int $result */
190194
$result = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'option' => $option]);
191195
$this->assertGreaterThan(0, $result);
196+
$updatedproductRepo = Bootstrap::getObjectManager()->create(ProductRepository::class);
197+
$updatedproduct = $updatedproductRepo->get($productSku);
198+
$this->assertEquals('configurable', $updatedproduct->getTypeId());
192199
}
193200

194201
/**

0 commit comments

Comments
 (0)