Skip to content

Commit 8df11a5

Browse files
committed
ACP2E-412: Cant link configurable options with REST to product created on Backend
1 parent 6c38ae4 commit 8df11a5

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ public function save($sku, OptionInterface $option)
230230
if ($product->getTypeId() === ProductType::TYPE_SIMPLE) {
231231
$product->setTypeId(ConfigurableType::TYPE_CODE);
232232
$product->save();
233-
}
233+
}//echo $option->getId()."ooo".$product->getTypeId();
234234
$option->save();
235235
} catch (\Exception $e) {
236236
throw new CouldNotSaveException(__('An error occurred while saving the option. Please try to save again.'));
237237
}
238238

239239
if (!$option->getId()) {
240240
throw new CouldNotSaveException(__('An error occurred while saving the option. Please try to save again.'));
241-
}echo $option->getId()."ooo".$product->getTypeId();
242-
return $option->getId()."ooo".$product->getTypeId();
241+
}
242+
return $option->getId();
243243
}
244244

245245
/**

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
namespace Magento\ConfigurableProduct\Api;
1010

11-
use Magento\Catalog\Model\ProductRepository;
1211
use Magento\TestFramework\Helper\Bootstrap;
12+
use Magento\Catalog\Model\ProductRepository;
1313
use Magento\Eav\Api\AttributeRepositoryInterface;
1414

1515
/**
1616
* Class OptionRepositoryTest for testing ConfigurableProductoption integration
1717
*/
1818
class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstract
1919
{
20-
public const SERVICE_NAME = 'configurableProductOptionRepositoryV1';
21-
public const SERVICE_VERSION = 'V1';
22-
public const RESOURCE_PATH = '/V1/configurable-products';
20+
const SERVICE_NAME = 'configurableProductOptionRepositoryV1';
21+
const SERVICE_VERSION = 'V1';
22+
const RESOURCE_PATH = '/V1/configurable-products';
2323

2424
/**
2525
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
@@ -190,15 +190,12 @@ public function testAdd(): void
190190
]
191191
],
192192
];
193-
/** @var string $result */
193+
/** @var int $result */
194194
$result = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'option' => $option]);
195-
echo "-------------------->>>>>>>".$result;
196-
$arr = explode("ooo", $result);
197-
$this->assertEquals('configurable', $arr[1]);
198-
$productRepository1 = Bootstrap::getObjectManager()->create(ProductRepository::class);
199-
$updatedproduct = $productRepository1->get($productSku);
195+
$this->assertGreaterThan(0, $result);
196+
$updatedproductRepo = Bootstrap::getObjectManager()->create(ProductRepository::class);
197+
$updatedproduct = $updatedproductRepo->get($productSku);
200198
$this->assertEquals('configurable', $updatedproduct->getTypeId());
201-
//$this->assertGreaterThan(0, $result);
202199
}
203200

204201
/**

0 commit comments

Comments
 (0)