Change HTTP Status Code in Plugin Controller


(Leif Hartmann) #1

Hi,

I am currently creating a “product details” page. The products are stored in the database and accessed as flow entities.

I thought I could create a single page and add a custom “ProductDetailsPlugin” to load the product data. It works as expected, but I miss an option to change the HTTP status code to 404, if a product is not found.

I tried changing the Response and the ParentResponse:

$this->response->getParentResponse()->setStatus(404);
$this->response->setStatus(404);

But I guess the status code is changed to 200 after that.

Is there some way to change the parent response from a Controller called from a plugin?