For every order I add dropdown that admin user can assign order to another "Pickup location". When user click button "Assign" I call Ajax and in controller change/update "Pickup" (Print Screeen bellow).
Problem, that I have is that when I want to assign to another "Pickup Location" and then save it, this extension attribute isn't syn with sales_order_grid.pickup_location_code.
How to achive that when I set new location that It will be updated also in sales_order_grid?
Code of my controller:
/** @var OrderRepositoryInterface */
private OrderRepositoryInterface $orderRepository;
/**
* Update constructor.
* @param OrderRepositoryInterface $orderRepository
*/
public function __construct(
Context $context,
OrderRepositoryInterface $orderRepository
)
{
$this->orderRepository = $orderRepository;
parent::__construct($context);
}
/**
* @inheritDoc
*/
public function execute()
{
$response = [];
$isAjax = $this->getRequest()->getParam("isAjax");
if($isAjax) {
$pickLocationCode = $this->getRequest()->getParam("code");
$orderId = $this->getRequest()->getParam("order_id");
try {
$order = $this->orderRepository->get($orderId);
$order->getExtensionAttributes()->setPickupLocationCode($pickLocationCode);
$this->orderRepository->save($order);
$respose["sucess"] = true;
$respose["message"] = "Order successfully assigned to other shop";
} catch (Exception $e) {
$respose["error"] = true;
$respose["message"] = $e->getMessage();
}
}
$resutJson = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_JSON);
return $resutJson->setData($respose);
}
}