浏览文章

文章信息

Magento2 跳转相关类、设置站内外跳转,跳转URL 13934

相关代码

    protected $resultFactory;
    public function __construct(
        \Magento\Framework\Controller\ResultFactory $resultFactory,
        \Magento\Framework\App\Action\Context $context)
    {
        $this->resultFactory = $resultFactory;
        parent::__construct($context);
    }
    public function execute()
    {
        $redirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
        $redirect->setUrl('/redirect/to/destination');
        return $redirect;
    }


原创