Skip to content

Commit f703aef

Browse files
committed
MC-43163: [Cloud] [Premier Support] Cannot update only extension attributes via REST (POST: /rest/V1/orders)
1 parent c2c5ec4 commit f703aef

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

app/code/Magento/Sales/Model/ResourceModel/EntityAbstract.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ protected function updateObject(\Magento\Framework\Model\AbstractModel $object)
179179
$condition = $this->getConnection()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
180180
$data = $this->_prepareDataForSave($object);
181181
unset($data[$this->getIdFieldName()]);
182-
$this->getConnection()->update($this->getMainTable(), $data, $condition);
182+
if (count($data) > 0) {
183+
$this->getConnection()->update($this->getMainTable(), $data, $condition);
184+
}
183185
}
184186

185187
/**

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUpdateTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,43 @@ public function testOrderStatusUpdate()
167167
);
168168
}
169169

170+
/**
171+
* Check order increment id after updating via webapi
172+
*
173+
* @magentoApiDataFixture Magento/Sales/_files/order.php
174+
*/
175+
public function testOrderNoAttributesProvidedUpdate()
176+
{
177+
/** @var Order $order */
178+
$order = $this->objectManager->get(Order::class)
179+
->loadByIncrementId(self::ORDER_INCREMENT_ID);
180+
181+
$entityData = $this->getOrderData($order);
182+
183+
$requestData = ['entity' => ['entity_id' => $entityData['entity_id']]];
184+
185+
$serviceInfo = [
186+
'rest' => [
187+
'resourcePath' => '/V1/orders',
188+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
189+
],
190+
'soap' => [
191+
'service' => self::SERVICE_NAME,
192+
'serviceVersion' => self::SERVICE_VERSION,
193+
'operation' => self::SERVICE_NAME . 'save',
194+
],
195+
];
196+
$result = $this->_webApiCall($serviceInfo, $requestData);
197+
$this->assertGreaterThan(1, count($result));
198+
199+
/** @var Order $actualOrder */
200+
$actualOrder = $this->objectManager->get(Order::class)->load($order->getId());
201+
$this->assertEquals(
202+
$order->getData(OrderInterface::INCREMENT_ID),
203+
$actualOrder->getData(OrderInterface::INCREMENT_ID)
204+
);
205+
}
206+
170207
/**
171208
* Prepare order data for request
172209
*

0 commit comments

Comments
 (0)