문제

I'm using the observer layout_generate_blocks_after to perform redirection to an empty cart on a condition but it is not redirecting. Any help would be appreciated.

Here is the piece of code which i try to do:

$cart->truncate();
$cart->save();

$redirectUrl = $this->urlBuilder->getUrl('checkout/cart'); 

$this->_responseFactory->create()->setRedirect($redirectUrl)->sendResponse();
die();
도움이 되었습니까?

해결책

The event 'layout_generate_blocks_after' will not fire on full page cache pages. It's only generated during the initial page render on a non-cache page.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top