cancel
Showing results for 
Search instead for 
Did you mean: 

When disable a custom module by admin how to truncate associated table of it?

SOLVED

When disable a custom module by admin how to truncate associated table of it?

Hello, 

I need to truncate the tables of a custom module when admin disable it in backend. There is any function for it. ? How can we do it ?

 

Could you please help?

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: When disable a custom module by admin how to truncate associated table of it?

Hi @arun_tr1 

Did it work for you?

View solution in original post

6 REPLIES 6

Re: When disable a custom module by admin how to truncate associated table of it?

Hi @arun_tr1,

 

One thing, when we disable custom module by admin then it is not fully disabled. It disable module output only. 

You need to disable from app/etc/modules/MODULE_XML_FILE.xml. 
You need to edit that file and make : 
<active>true</active> to <active>false</active>

There is not any direct way to truncate table for disable module. You can truncate from the database.

TRUNCATE TABLE TABLE_NAME;

I hope it will help you!

Re: When disable a custom module by admin how to truncate associated table of it?

Hi @Vimal Kumar 

 

Thanks for your help but i have a little doubt on it. How we can make the change dynamically in code level. Is there any way ? Also i don't have such file (app/etc/modules/MODULE_XML_FILE.xml).

 Is need to create it?  I am a beginner in magento so could you please help me to solve this?

 

Thank you!

Re: When disable a custom module by admin how to truncate associated table of it?

There will not be same file as I mentioned in above comment.

There will be a module file, like ModuleNamespace_Modulename.xml.

For example: Mage_Catalog.xml ( this is only example, you don’t need to change this file.)

For change dynamic code, you need to edit the code or comment the code.

I hope it will help you!

Re: When disable a custom module by admin how to truncate associated table of it?

Hi @Vimal Kumar 

 

Thanks for your great effort. But my requirement is to truncate the table dynamically when admin disable that custom module, is there any function triggered or is any way to trigger a function truncate the table at the same time admin disable that module.

It will be great have a solution for it.

 

Thank you!

   

Re: When disable a custom module by admin how to truncate associated table of it?

No, there is no any direct way in magento to truncate database table when you disable the module.

You can truncate the table directly from database using mysql.

Re: When disable a custom module by admin how to truncate associated table of it?

Hi @arun_tr1 

Did it work for you?