1

I have created custom module in Magento 2.
In stores->configuration i have created two tabs.
now my requirement is to open second tab when save the first tab configuration. am doing save operation using observer.
kindly let me know that how to redirect from one tab to another tab.

  • After saving the information, you redirect back to the same URL, right? To open the necessary tab, you can add "/active_tab/<tab_id>/" to the URL. Is that what you was asking about? – MagestyApps Aug 18 '16 at 13:45
  • yes you are right, but in Magento 2 i dono how to do redirect operation – Priya Ponnusamy Aug 19 '16 at 4:37
2
<?php
namespace [Vendor]\[modulename]\Observer;
use Magento\Framework\Event\ObserverInterface;

class [YourClass] implements ObserverInterface
{
protected $_responseFactory;
protected $_url;

public function __construct(

    \Magento\Framework\App\ResponseFactory $responseFactory,
    \Magento\Framework\UrlInterface $url
) {
    $this->_responseFactory = $responseFactory;
    $this->_url = $url;
}

public function execute(Observer $observer) {
    $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $storeManager = $_objectManager->get('Magento\Store\Model\StoreManagerInterface'); 
    $currentStoreId = $storeManager->getStore()->getId();
    $currentWebsiteId = $storeManager->getStore()->getWebsiteId();
    $RedirectUrl= $this->_url->getUrl('*/*/edit', array('_current' => array('section name here', 'website here', 'store here)));
    $this->_responseFactory->create()->setRedirect($RedirectUrl)->sendResponse();
    die();
}
}

Your Answer

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

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