I am working on a Magento 2 extension that will send a message to me when a new product review is written. I’ve tried to create an observer, but it never seems to work.
In ets/events.xml
, I have this:
<event name="review_save_after">
<observer
name = "jeroen_update_product_review"
instance = "JeroenReviewIntegrationObserverProductReview" />
</event>
In JeroenReviewIntegrationObserverProductReview
:
namespace JeroenReviewIntegrationObserver;
use MagentoFrameworkEventObserverInterface;
class ProductReview implements ObserverInterface
{
protected $_storeManager;
protected $_request;
public function __construct(
MagentoStoreModelStoreManagerInterface $storeManager,
MagentoFrameworkAppRequestHttp $request
) {
$this->_storeManager = $storeManager;
$this->_request = $request;
}
public function execute(MagentoFrameworkEventObserver $observer)
{
return 'test';
}
}
This always gives a a blank page after a new review is written (and after the status of the review is updated). Can anyone find out what I am doing wrong?
3
Answers
Thanks for your replies! I found out that it was just a caching error. De code needed to be recompiled before it worked. Thanks anyway for your answers.
Make sure you set enough memory_limit in php.ini
php.ini values are:
post_max_size = 1024M
upload_max_filesize = 1024M
memory_limit = 3G
max_execution_time = 500
We can use Plugin to achieve any functionality after review save