Skip to content

Commit 9bb26f4

Browse files
author
Eric Bohanon
committed
MAGETWO-83872: Write metadata service
1 parent 69f9ef2 commit 9bb26f4

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/ProductRepositoryInterfaceTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ protected function getSimpleProductData($qty = 1000)
193193
if ($qty != null) {
194194
$productData[self::KEY_CUSTOM_ATTRIBUTES] = [
195195
[self::KEY_ATTRIBUTE_CODE => 'description', 'value' => 'My Product Description'],
196-
[self::KEY_ATTRIBUTE_CODE => self::CODE_QUANTITY_AND_STOCK_STATUS, 'value' => [true, $qty]],
196+
[
197+
self::KEY_ATTRIBUTE_CODE => self::CODE_QUANTITY_AND_STOCK_STATUS,
198+
'value' => ['is_in_stock' => true, 'qty' => $qty]
199+
],
197200
];
198201
}
199202

@@ -271,6 +274,15 @@ protected function getProduct($sku)
271274
*/
272275
protected function saveProduct($product)
273276
{
277+
if (isset($product['custom_attributes'])) {
278+
for ($i=0; $i<sizeof($product['custom_attributes']); $i++) {
279+
if ($product['custom_attributes'][$i]['attribute_code'] == 'category_ids'
280+
&& !is_array($product['custom_attributes'][$i]['value'])
281+
) {
282+
$product['custom_attributes'][$i]['value'] = [""];
283+
}
284+
}
285+
}
274286
$serviceInfo = [
275287
'rest' => [
276288
'resourcePath' => self::RESOURCE_PATH,
@@ -295,6 +307,15 @@ protected function saveProduct($product)
295307
*/
296308
protected function updateProduct($product)
297309
{
310+
if (isset($product['custom_attributes'])) {
311+
for ($i=0; $i<sizeof($product['custom_attributes']); $i++) {
312+
if ($product['custom_attributes'][$i]['attribute_code'] == 'category_ids'
313+
&& !is_array($product['custom_attributes'][$i]['value'])
314+
) {
315+
$product['custom_attributes'][$i]['value'] = [""];
316+
}
317+
}
318+
}
298319
$sku = $product[ProductInterface::SKU];
299320
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_REST) {
300321
$product[ProductInterface::SKU] = null;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@ protected function deleteProductBySku($productSku)
461461
*/
462462
protected function saveProduct($product)
463463
{
464+
if (isset($product['custom_attributes'])) {
465+
for ($i=0; $i<sizeof($product['custom_attributes']); $i++) {
466+
if ($product['custom_attributes'][$i]['attribute_code'] == 'category_ids'
467+
&& !is_array($product['custom_attributes'][$i]['value'])
468+
) {
469+
$product['custom_attributes'][$i]['value'] = [""];
470+
}
471+
}
472+
}
464473
$resourcePath = self::RESOURCE_PATH . '/' . $product['sku'];
465474
$serviceInfo = [
466475
'rest' => [

0 commit comments

Comments
 (0)