How can I programmatically build this url: http://127.0.0.1/magento2/sales/order/view/order_id/61/?

Im in a custom controller with the current Order object.

有帮助吗?

解决方案

Please get website's base URL from this code:

public $_storeManager; public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, ..... ) { ... $this->_storeManager=$storeManager; } $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);

$orderUrl = $url.'sales/order/view/order_id/'.$orderId;

You can pass $orderUrl in your external API.

许可以下: CC-BY-SA归因
scroll top