0

My site uses varnish cache heavily and is set to refresh every 5 minutes. I found out that this was skewing product view stats making them less than what they actually should be.

  1. I want to turn off Magentos default product view logging facility so that no product views are being recorded.

  2. I want to mimic the action by doing custom inserts into the relevant tables i.e. tf_report_viewed_product_index

Inserting into the tf_report_viewed_product_index table alone is not allowed since it has foriegn key constraints. There is more to it.

nickhar
  • 19,981
  • 12
  • 60
  • 73

2 Answers2

1

In case anyone comes across this you can use xml to disable an event:

<frontend>
        <events>
            <catalog_controller_product_view>
                <observers>
                    <reports>
                        <type>disabled</type>
                    </reports>
                </observers>
            </catalog_controller_product_view>    
        </events>
    </frontend>

Then using an ajax call from the product view page I simply insert a new row into tf_report_viewed_product_index table.

0

This is not a Magento issue, this is a user-request-reaching-your-web-app (Magento) issue. The speed and load-handling benefits realized by using Varnish exist precisely because pre-generated static content is cached and served ahead of the dynamically generated content from Magento (which also includes the overhead and resources of logging traffic to the report_* and log_* tables).

I've not too much experience in this area, but I believe you should use varnishcsa to log cache hits and then process them via cron using the Magento Report module's modeling; see Mage_Reports_Model_Event_Observer::catalogProductView() for a start, but note that this method normally handles logging of single views. You will likely want to do a mass insert of processed Varnish log data and then calculate.

And, here's a link SO post on setting up logging with varnishcsa.

Community
  • 1
  • 1
benmarks
  • 23,384
  • 1
  • 62
  • 84
  • Thanks benmarks this is a decent solution to the problem. I've started working on a solution which I will share below. – user2244725 May 09 '13 at 13:38