Tuesday, May 31, 2011

Disabling customer logging

All the tables that start with 'log_' become pretty big after some uptime.
If you don't need these here is a solution to disable them.
[UPDATE]
It seams that the product compare feature is based on this logging. If you disable all the logging you won't be able to compare products. This is a big no-no Magento Team. (see the logging methods marked in the xml below)
[/UPDATE] Create your own Magento extension. Let's call it 'Custom_Log'.
For this you need to create in app/code/local the folder 'Custom' and inside it the folder 'Log'.
Each module needs a config file.
Create inside the 'Log' folder a folder named 'etc' and inside it a file called config.xml with this content:
<?xml version="1.0"?>
<config>
    <modules>
         <Custom_Log>
            <version>0.0.1</version>
        </Custom_Log>
    </modules>
    <frontend>
 <!-- [+] Disable logging -->
   <events>
            <controller_action_predispatch><!--disabling this will 'kill' the product compare-->
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </controller_action_predispatch>
            <controller_action_postdispatch><!--disabling this will 'kill' the product compare-->
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </controller_action_postdispatch>
            <customer_login>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </customer_login>
            <customer_logout>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </customer_logout>
            <sales_quote_save_after>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </sales_quote_save_after>
            <checkout_quote_destroy>
                <observers>
                    <log>
                        <type>disabled</type>
                    </log>
                </observers>
            </checkout_quote_destroy>
        </events>
   <!-- [-] Disable logging -->
    </frontend>
</config>

now you need to tell Magento to use your module.
In app/etc/modules create the file 'Custom_Log.xml' with this content:
<?xml version="1.0"?>
<config>
    <modules>
        <Custom_Log>
            <active>true</active>
            <codePool>local</codePool>
        </Custom_Log>
    </modules>
</config>

now just clear the cache (contents of folder var/cache) and you are done.
The downside of doing this is that you won't get any details of the customers visits. But you can live with that. There's Google Analytics for this.

No comments:

Post a Comment