Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top