Skip to content

Instantly share code, notes, and snippets.

@mohfahrul
Last active March 31, 2022 07:24
Show Gist options
  • Save mohfahrul/c50bb95e0ce98b850f2498674dfb0872 to your computer and use it in GitHub Desktop.
Save mohfahrul/c50bb95e0ce98b850f2498674dfb0872 to your computer and use it in GitHub Desktop.
Magento Redirect using { $this->_redirect } on Controller
<?php
namespace Icube\Training\Controller\Index;
use \Magento\Framework\App\Action\Action;
use \Magento\Framework\App\Action\Context;
class Example extends Action
{
protected $traineeFactory;
public function __construct(
Context $context,
\Icube\Training\Model\TraineeFactory $traineeFactory,
){
$this->traineeFactory = $traineeFactory;
parent::__construct($context);
}
public function execute()
{
// redirect to path -> {baseUrl}/Training/
// $this->_redirect is default function that inherit from parent class Action
$this->_redirect('training/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment