I have the following requirement: my URLs can be any of the following
I want to capture the resid
value and place it in the backend and save it along the order the customer makes.
I.e., if ?resid=133
is requested and the customer later proceeds to make an order, I want the resid
to be saved (133) along with the order id (say 100000123).
And later I want the resid
value to be shown in the sales order grid (in admin).
Can somebody guide me in doing this?
You can get Post Data value in the After plugin using Magento 2. You can get all the Params() data after the plugin which is sent by request. If you send the query string Or data within the URL, you can get those data using getParams() in the after plugin.
If you need to get current URL in Magento 2 PHTML file the easiest way to do this is to use the following code: $currentUrl = $block->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]); This is the best method since you don't even need to use the Object Manager.
Magento 2, Get Referer url by calling function getRefererUrl() or getRedirectUrl() from RedirectInterface Object. Magento core Interface, Magento\Framework\App\Response\RedirectInterface used for fetch Referer URL.
Also known by the aliases of query strings or URL variables, parameters are the portion of a URL that follows a question mark. They are comprised of a key and a value pair, separated by an equal sign. Multiple parameters can be added to a single page by using an ampersand.
In the controller do $this->getRequest()->getParam('resid')
to get the value. Save that in the user's session. To save it in the order, you have to add a field to the Order table then you can add it to the Order object once its created. You'll have to then overwrite the Grid Block used to display orders to add that field to the grid. It'll be a lot of work to do this all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With