Skip to main content
The 2024 Developer Survey results are live! See the results
13 votes
Accepted

Add query parameter to current url in phtml

Try this $current_url = $this->getUrl('*/*/*', array('_current' => true,'_use_rewrite' => true, '_query' => $your_query)); Where $your_query = array('new_query' => 123)
Piyush's user avatar
  • 5,904
10 votes
Accepted

Magento2: How to check if request is from Web Service?

I used Magento\Framework\App\State::getAreaCode() to find if request is coming via SOAP / REST API. You can check the possible area codes in Magento\Framework\App\Area class.
MagePsycho's user avatar
  • 4,628
7 votes
Accepted

Magento and HTTP/2 : what is the current status?

There is no problem with HTTP/2 "just working". But there is opportunity for further optimization. My understanding is it is worth looking into capabilities of your CDN provider if you want to take ...
Alan Kent's user avatar
  • 3,498
6 votes

Magento 2: Sending a Custom Header/Response from a Controller

In Magento 2.1 and above, easiest way is to use the result factory: public function execute() { $resultPage = $this->resultFactory ->create(ResultFactory::TYPE_JSON) ->...
Erfan's user avatar
  • 3,117
5 votes
Accepted

How do I get Http_referer path without "http://localhost/index.php/"?

Well you use PHP native method parse_url() : http://php.net/manual/en/function.parse-url.php var_dump(parse_url(Mage::helper('core/http')->getHttpReferer())); It will give you the following ...
Raphael at Digital Pianism's user avatar
5 votes

Redirect all http:// request to https://

Make sure System > Configuration > Web > url_options > "Auto-redirect to Base URL = No". It was set to yes, and causing the problem. Put below code in .htaccess file. RewriteCond %{HTTP:...
Vikas Verma's user avatar
4 votes
Accepted

How to avoid using php://input?

Assuming $this->request is an instance of Magento\Framework\App\Request\Http, you can use the code below to get the JSON post body. $json = $this->request->getContent(); $data = json_decode($...
fmsthird's user avatar
  • 4,602
4 votes

Magento and HTTP/2 : what is the current status?

You definitely can use Http/2 with any version of Magento. And yes, you need to enable https for all pages (it's recommended setup for M2, why do you not did it before). Also, bundling of js files don'...
KAndy's user avatar
  • 20.9k
4 votes

Magento 2 increase site speed

Some important points for speeding up Magento 2:: Production Mode Full Page Cache Minify JS and CSS Check TTFB and try to reduce it Enable Flat Categories and Products Enable GZIP ...
Saphal Jha's user avatar
  • 1,883
3 votes

Magento and HTTP/2 : what is the current status?

If you want to set all pages to HTTPS, you might also want to enable HSTS (More info: https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security). For the rest of it, I never had any trouble using ...
Arjen Miedema's user avatar
3 votes

Magento2 how to getRequest

This should work, just test it. Compare and see what is missing. <?php namespace MyModuleNameSpace\MyModule\Block use Magento\Framework\App\RequestInterface; class MyClass extends \Magento\...
Daniel's user avatar
  • 41
3 votes
Accepted

What to replace deprecated Class 'Zend_Rest_Client' with in Magento 2.3?

You are correct in that Magento deprecated the Zend_Rest module and a bunch of others. You can find a full list here https://devdocs.magento.com/guides/v2.3/release-notes/backward-incompatible-changes/...
Sam's user avatar
  • 1,910
3 votes
Accepted

Magento 2 frontend route only allow POST method

Magento request object has a function $this->getRequest()->getMethod() which provide the request method name on request object. So using this getMethod(),you can prevent your route from all ...
Amit Bera's user avatar
  • 77.6k
3 votes

Getting information about a request using HttpGetActionInterface

<?php ... use Magento\Framework\App\RequestInterface; class ... { protected $request; public function __construct( ... RequestInterface $request ) { ....
Nilesh Dubey's user avatar
  • 1,087
2 votes
Accepted

Magento 1: unset a previously set query parameter or reinit the request

Magento 1 does not have a "proper Magento way" for integration tests because it does not have them. The EcomDev_PHPUnit framework replaces Mage_Core_Controller_Request_Http with an extended version ...
Fabian Schmengler's user avatar
2 votes

Braintree - 400 Bad Request Message on checkout

I have tried in my local magento 2 and setup the Braintree Sandbox details. Please follow the below screenshots: Admin end settings: Admin end settings: Onestep checkout page : After place order ...
Nagaraju Kasa's user avatar
2 votes

Redirect all http:// request to https://

The Apache docs recommend against using a rewrite: To redirect http URLs to https, do the following: <VirtualHost *:80> ServerName www.example.com Redirect / https://www.example.com/...
Rakesh Soni's user avatar
2 votes

Magento 2: getPost and getPostValue methods on the request object

To get Post data in controller you need to use following in your execute function. public function execute(){ $post = $this->getRequest()->getPostValue(); echo "<pre>"; ...
Shyam Hajare's user avatar
2 votes

retrieving http header info

I'm assuming you're using Magento (based on the fact this is magento.stackoexchange.com). It is bad form to use webserver-specific functions in application level code. Magento has built in utilities ...
siliconrockstar's user avatar
2 votes

Triggering a 404, 500, 503 error in Magento 2

As suggested by @Anton Kril, this worked for me. namespace Company\ModuleName\Controller\Index; use Magento\Framework\App\Action\Context; use \Magento\Framework\Exception\NotFoundException; ...
Muhammad Saeed Khan's user avatar
2 votes

Magento2: How to check if request is from Web Service?

I had a similar task once, and if I remember correctly I did this by checking if \Magento\Framework\App\Request\Http::getFullActionName() equals __. I don't know why, but for REST requests this would ...
Giel Berkers's user avatar
  • 12.3k
2 votes
Accepted

set x-frame-options in custom controller magento2

I tried a few different versions of setHeader() but the only thing that worked for me was overwriting XFrameOptions. Vendor/Module/etc/di.xml <?xml version="1.0"?> <config ...
Silas Palmer's user avatar
2 votes

Magento 2 frontend route only allow POST method

If you use M 2.3 then easily use that. You controller should implements the following interface: Magento\Framework\App\Action\HttpPostActionInterface Check contact module post action how it's use
Sohel Rana's user avatar
2 votes
Accepted

Why is my Magento 2 site loading very slowly?

Try enabling profiler and then find out which block or template is taking much time and memory. Try scanning from bottom to top in the profiler. In most cases, 3rd party extensions are responsible for ...
Mannu's user avatar
  • 36
2 votes
Accepted

Getting information about a request using HttpGetActionInterface

httpgetactioninterface does not provide the request interface. To get Request information you have to inject/use Magento\Framework\App\RequestInterface which is behave like $this->getRequest()
Amit Bera's user avatar
  • 77.6k
1 vote

In CRUD, Why delete item operation is preferred via POST request rather than GET request?

As per the CRUD Operations, we use GET request to Read information with the request You can have a reference here And for Create or Update Request we use POST Requests That's why while deletion we ...
Arun Vishwakarama's user avatar
1 vote
Accepted

Generate Adminhtml Controller url with get parameter in Block

For multiple querystring variable <?php $params = [ 'order_id' => $block->getOrderId(), 'website_id' => $block->getWebsiteId(), ]; ?> $url = $block->getUrl('...
Rakesh Jesadiya's user avatar
1 vote

Change http to https in magento

My hosting service recommended this site: https://www.whynopadlock.com/ You can check individual pages for insecure content.
John's user avatar
  • 11
1 vote

Magento2: How to check if request is from Web Service?

Please check with below code, public function __construct(\Magento\Framework\Event\Observer $observer) { $controller = $observer->getControllerAction(); } $isApirequest = $controller->...
Rakesh Jesadiya's user avatar
1 vote
Accepted

usatilea.nextmp.net is currently unable to handle this request

I think this is php version issue your current magento version is not compatible with php version. solution 1 install php 5.6 solution 2 upgrade magento version
Qaisar Satti's user avatar
  • 32.5k

Only top scored, non community-wiki answers of a minimum length are eligible