如何覆盖Magento产品视图日志记录

时间:2013-05-09 10:31:30

标签: magento

我的网站大量使用清漆缓存,并设置为每5分钟刷新一次。我发现这会扭曲产品视图统计数据,使其低于实际应有的数据。

  1. 我想关闭Magentos默认产品视图记录工具,以便不记录产品视图。

  2. 我想通过在相关表格中进行自定义插入来模仿操作,例如tf_report_viewed_product_index

  3. 不允许单独插入tf_report_viewed_product_index表,因为它具有foriegn键约束。还有更多。

2 个答案:

答案 0 :(得分:1)

如果有人遇到此问题,您可以使用xml来禁用事件:

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

然后在产品视图页面中使用ajax调用,我只需在tf_report_viewed_product_index表中插入一个新行。

答案 1 :(得分:0)

这不是Magento问题,这是一个用户请求到达您的网络应用(Magento)问题。使用Varnish实现的速度和负载处理优势正是因为预先生成的静态内容在Magento动态生成的内容之前被缓存和提供(其中还包括将流量记录到report_*log_*表)。

我在这方面没有太多经验,但我相信您应该使用varnishcsa来记录缓存命中,然后使用Magento Report模块的建模通过cron处理它们;请参阅Mage_Reports_Model_Event_Observer::catalogProductView()作为开始,但请注意,此方法通常会处理单个视图的日志记录。您可能希望大量插入已处理的Varnish日志数据,然后进行计算。

而且,here's a link SO post on setting up logging with varnishcsa