Skip to content

Commit

Permalink
2.4.11 - Bug - when updating an order from the API Magento do not pas…
Browse files Browse the repository at this point in the history
…s the customer_id of the order
  • Loading branch information
bnayalivne committed May 18, 2021
1 parent c58d64e commit 76d9931
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Model/Api/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ public function setConfig($mage_store_id, $configName, $scope, $newValue)
*/
public function getVersion()
{
return '2.4.10';
return '2.4.11';
}

/**
Expand Down
13 changes: 11 additions & 2 deletions Serializer/OrderSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Remarkety\Mgconnector\Serializer;

use Magento\Customer\Model\ResourceModel\CustomerRepository;
use Magento\Sales\Model\OrderRepository;
use Magento\Newsletter\Model\Subscriber;
use Magento\Sales\Model\Order\Shipment;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
Expand All @@ -15,6 +16,7 @@ class OrderSerializer
use CheckSubscriberTrait;

private $customerRepository;
private $orderRepository;
private $statusCollection;
private $remarketyHelper;

Expand All @@ -26,6 +28,7 @@ class OrderSerializer

public function __construct(
CustomerRepository $customerRepository,
OrderRepository $orderRepository,
\Magento\Sales\Model\ResourceModel\Order\Status\Collection $statusCollection,
\Remarkety\Mgconnector\Helper\Data $remarketyHelper,
AddressSerializer $addressSerializer,
Expand All @@ -42,6 +45,7 @@ public function __construct(
$this->subscriber = $subscriber;
$this->dataOverride = $dataOverride;
$this->configHelper = $configHelper;
$this->orderRepository = $orderRepository;
}

public function serialize(\Magento\Sales\Model\Order $order)
Expand Down Expand Up @@ -93,7 +97,6 @@ public function serialize(\Magento\Sales\Model\Order $order)
$itemTax = 0;
}
$itemArr = [
//'product_parent_id' => $rmCore->getProductParentId($item->getProduct()),
'product_id' => $item->getProductId(),
'sku' => $item->getSku(),
'quantity' => $lineQty,
Expand All @@ -114,7 +117,13 @@ public function serialize(\Magento\Sales\Model\Order $order)
$updated_at = new \DateTime($order->getUpdatedAt());

if (!$order->getCustomerIsGuest()) {
$customer = $this->customerRepository->getById($order->getCustomerId());
if(empty($order->getCustomerId())){
//When updating an order using the POST /rest/V1/orders API we are not getting customer id on the object
$tmpOrder = $this->orderRepository->get($order->getEntityId());
$customer = $this->customerRepository->getById($tmpOrder->getCustomerId());
} else {
$customer = $this->customerRepository->getById($order->getCustomerId());
}
$customerInfo = $this->customerSerializer->serialize($customer);
} else {
if ($this->configHelper->getCustomerAddressType() === ConfigHelper::CUSTOMER_ADDRESS_BILLING) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lib-libxml": "*"
},
"type": "magento2-module",
"version": "2.4.10",
"version": "2.4.11",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Remarkety_Mgconnector" setup_version="2.4.10">
<module name="Remarkety_Mgconnector" setup_version="2.4.11">
</module>
</config>

0 comments on commit 76d9931

Please sign in to comment.