0

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).

Dropdown menu

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);
}

}

2
  • Flushing the cache and reloading the sales order grid updates the value? Aug 17, 2021 at 14:26
  • No. It doesn't change anything. I was trying with cron also (docs.magento.com/user-guide/sales/…). How exactly Magento syn these values/columns when order is placed? Aug 17, 2021 at 19:16

0

Your Answer

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

Browse other questions tagged or ask your own question.