We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    If you want to redirect link with query string parameters using Magento ResultFactory, then you can use below script.

    You can make a link with a query string using  MagentoFrameworkUrlInterface;

    Here I have used that in the controller file.

    <?php
    namespace VendernameModulenameControllerIndex;
    use MagentoFrameworkControllerResultFactory;
    use MagentoFrameworkAppActionAction;
    use MagentoFrameworkAppActionContext;
    use MagentoFrameworkAppRequestDataPersistorInterface;
    use MagentoFrameworkViewElementMessages;
    use MagentoFrameworkDataObject;
    use MagentoFrameworkUrlInterface;
    
    class Post extends Action
    {
    
    
    protected $_inlineTranslation;
    protected $_transportBuilder;
    protected $_scopeConfig;
    protected $_logLoggerInterface;
    protected $urlBuilder;
    protected $_attributeRepository;
    
    public function __construct(
    MagentoFrameworkAppActionContext $context,
    MagentoFrameworkTranslateInlineStateInterface $inlineTranslation,
    MagentoFrameworkMailTemplateTransportBuilder $transportBuilder,
    MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig,
    PsrLogLoggerInterface $loggerInterface,
    UrlInterface $urlBuilder,
    MagentoCatalogModelProductAttributeRepository $AttributeRepository,
    array $data = []
    
    )
    {
    $this->_inlineTranslation = $inlineTranslation;
    $this->_transportBuilder = $transportBuilder;
    $this->_scopeConfig = $scopeConfig;
    $this->_logLoggerInterface = $loggerInterface;
    $this->messageManager = $context->getMessageManager();
    $this->urlBuilder = $urlBuilder;
    $this->_attributeRepository = $AttributeRepository;
    
    
    parent::__construct($context);
    
    
    }
    
    public function execute()
    {
    $argument = array('q' => 'test');
    $redirecturl = $this->urlBuilder->getUrl('set-your-redirect-path', ['_current' => true,'_use_rewrite' => true, '_query' => $argument]);
    return $this->resultRedirectFactory->create()->setUrl($redirecturl);
    }
    
    
    }

    Note: I have tried this code with Magento 2.3.5 version.

    field_5bfb909c5ccae

      Get a Free Quote