View Single Post
Old 07-23-2020, 07:55 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline

Join Date: Apr 2007
Posts: 14,096

Default Decorate a class isVisible method or delete the class view

I hope XC tech or someone else who faced this before can shed some light.

Here is the scenario.
There is a 3rd party Module A that adds block of html to a page. Nothing special - it extends the AView class and uses ListChild in the class to place the html block on the page
Now I need to stop this from showing the html block. So I have custom module and will have code to do this. Possible actions:

1. I can edit the template itself with the template editor and comment out the code. However I try to stay away from this. And doing it this way the class will still execute and the code will run. I don't want that. Also since this is related to the custom module it has to work only if that module is active which is not the case if template is modified through the template editor.

2. I can decorate the class from Module A and set its visible property to false.

3. OR I can use moveClassesInLists method in Main.php and delete the view for this class and list.

The question is which solution is better - 2 or 3?

With #2 I have to decorate the 3rd party class. But with this the class and its code will not run.

With #3 there is no decoration of the 3rd party module so all the code is contained within my custom module and runs conditionally anyway. However I think in this case the code from the 3rd party module View class will still run but the html block won't show because the view is deleted from the list.

So which one is better?
Both 2 and 3 work just fine and the end result is as expected. Which one though is faster and with less overhead to the cart in general. Anyone?

I am leaning more towards #2
Steve Stoyanov
Web Development
Reply With Quote