1

The model listener is calling 3 to 4 time for each update in layout., how to avoid this.

@Override
        public void onAfterUpdate(Layout model) throws ModelListenerException {
    System.out.println("The model lisnters called for layout update");
    }
Ravi R
  • 73
  • 1
  • 11
  • I think this behaviour is intended, what kind of problem you have with it? – Marco Mercuri Jan 19 '18 at 16:06
  • Try to log all the attributes from Layout model and see what field is getting an update. – ravikuwi Jan 19 '18 at 17:48
  • click on configure page and go to SEO and select some category & save it calls multiple time model listener will called – Ravi R Jan 20 '18 at 06:06
  • I have also noticed the model listeners are called several times. If you are trying to make sure things don't happen multiple times, one solution is to check a condition and only have your code execute if the condition is met. For example, if you're doing something on User onAfterUpdate, you could check that the user attributes in the database don't match the attributes on the User passed to the onAfterUpdate method. If you can't think of a condition that will identify whether or not your code needs to run, you could put a flag on thread local and set it to true after running your code. – clav Jan 22 '18 at 19:56
  • Have you got a solution ? I am facing the same problem – pratik patel Apr 22 '20 at 11:53

0 Answers0