What is the equivalent of Magento 1 to Magento 2?
Mage::app()->getResponse()
->setHeader('HTTP/1.1','503 Service Unavailable')
->sendResponse();
What is the equivalent of Magento 1 to Magento 2?
Mage::app()->getResponse()
->setHeader('HTTP/1.1','503 Service Unavailable')
->sendResponse();
In controller you can use following;
public function execute()
{
$this->getResponse()
->setStatusCode(\Magento\Framework\App\Response\Http::STATUS_CODE_503)
->setContent('503 Service Unavailable');
return ;
}
EDIT:
You can try injecting \Magento\Framework\Controller\ResultFactory in your class and calling
$this->response->setHeader('HTTP/1.1', '503 Service Unavailable', true); (if your object is $response) and return it at end.
$typeis missing. from$this->resultF->create()->setHeader('HTTP/1.1', '503 Service Unavailable', true);code – Manoj Kumar Feb 28 '18 at 06:27