I am wanting to run some code that makes a request on product save, separate to the page product save happens on.
I have correctly set up an observer that listens to the 'catalog_product_save_after' event and makes the request.
However, now when I save a product, the page waits for the observer to finish making the request before it continues and loads the 'success' page. What practice/functionality can I use such that the product save page defers the request, but doesn't need to wait on the result to continue.
Edit:
Here is the controller code that saves the product and redirects with the success message:
if (isset($data['variations-matrix'])) {
foreach ($data['variations-matrix'] as $matrixdata) {
$simpleids[] = $this->saveproduct($data, 'simple', $matrixdata, $blankarray = []);
}
$product_id = $this->saveproduct($data, 'configurable', $blankarray = [], $simpleids);
} else {
$product_id = $this->saveproduct($data, $data['product_type']);
}
$this->messageManager->addSuccess(__('The Product has been saved.'));
return $this->_redirect('marketplace/index/products');
Without an observer, the success message and redirect happen almost instantly. With an observer listening to catalog_product_save_after however, the redirect and message only happen once the request is run. I am looking for a way for the request to be triggered without product save waiting for the request to finish.