1

In my case. i visited to checkout page and logined. How to check current page is checkout and redirect back to it! Tried

   if($this->session->getCurrentPage() == 'checkout') {
        return $store->getUrl('checkout');
    }

3 Answers 3

2

Try this

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$urlInterface=$objectManager->create('Magento\Framework\UrlInterface');

echo $urlInterface->getCurrentUrl();
1
  • if need echo $urlInterface->getUrl() Commented Feb 28, 2017 at 10:20
2

Set block content with custom function :

protected $_request;

public function __construct(
    ...
    \Magento\Framework\App\Request\Http $request,
    ...
) {
    ...
    $this->_request = $request;
    ...
}

public function isHomepage()
{

    if ($this->_request->getFullActionName() == 'cms_index_index') {//cms_index_index your page identifier e.g. 'checkout_index_index' for checkout
        return true;
    }
    return false;
}

Template code :

<?php  $isHome = $block->isHomepage(); ?>
0
$this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.