I am trying to associate orders and customer using the following code.

$order = $this->orderRepo->get($oid);

Where orderRepo is Magento\Sales\Api\OrderRepositoryInterface

But save is not working as expected and I can’t see association in order details page/customer order section.

I have checked in the create method in \Magento\Sales\Model\Order\CustomerManagement and Magento is doing the same.

  • try to put code into try.....catch block, so if any error then it show there. Nov 16 '18 at 13:55
  • Does it save in the db? Nov 16 '18 at 15:04
  • @DhirenVasoya Nothing in try catch block. Nov 19 '18 at 4:42
  • @acf No, it is not saving in db as well. Nov 19 '18 at 4:45

I found the problem it was because some other module was loading the order object using Magento\Sales\Model\OrderFactory and setting some data and then calling save method of it.

I have solved my problem by calling my method after this module's processing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.