We can use below syntax to get current Url:
protected $_urlinterface;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\UrlInterface $urlinterface,
array $data = []
) {
parent::__construct($context, $data);
$this->_urlinterface = $urlinterface;
}
public function getCurrentUrl()
{
return $this->_urlinterface->getCurrentUrl(); // Give the current url of recently viewed page
}
protected $_urlinterface;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\UrlInterface $urlinterface,
array $data = []
) {
parent::__construct($context, $data);
$this->_urlinterface = $urlinterface;
}
public function getCurrentUrl()
{
return $this->_urlinterface->getCurrentUrl(); // Give the current url of recently viewed page
}
No comments:
Post a Comment