I have around 500 words which I want to banned them to be use on product add and user registration. How can i do that ?

I tried using the event and observer for catalog_product_save_after

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="catalog_product_save_after">
        <observer name="ghrix_bannedwords_banned" instance="Ghrix\BannedWords\Observer\Banned"  />

any other way to do globally ?



In such a case, you can use catalog_product_save_before event instead of catalog_product_save_after.If you define your events.xml at app/code/{Vendor}/{Modulename}/etc location then it is fire for all area.

For all save

Yes, you can do global using model_save_before event and entity_manager_save_before which is a fire during all data save using model and repository save

| improve this answer | |
  • can't we do globally ? so that it will work for customers too – Rahul Singh May 19 at 7:52
  • what you mean by globally? – Amit Bera May 19 at 7:53
  • globally in the sense, for any type of data save (whether customer or products) it will show error for banned words – Rahul Singh May 19 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.