0

I have a site that has recently viewed products not working for whatever reason. It could very much be because someone stripped out some part of the code somewhere that handles this functionality.

I was able to find the database table report_viewed_product_index which is defined as:

    <models>
        <reports>
            <class>Mage_Reports_Model</class>
            <resourceModel>reports_resource</resourceModel>
        </reports>
        <reports_resource>
            <class>Mage_Reports_Model_Resource</class>
            <deprecatedNode>reports_mysql4</deprecatedNode>
            <entities>
                <event>
                    <table>report_event</table>
                </event>
                <event_type>
                    <table>report_event_types</table>
                </event_type>
                <compared_product_index>
                    <table>report_compared_product_index</table>
                </compared_product_index>
                <viewed_product_index>
                    <table>report_viewed_product_index</table>
                </viewed_product_index>
                <viewed_aggregated_daily>
                    <table>report_viewed_product_aggregated_daily</table>
                </viewed_aggregated_daily>
                <viewed_aggregated_monthly>
                    <table>report_viewed_product_aggregated_monthly</table>
                </viewed_aggregated_monthly>
                <viewed_aggregated_yearly>
                    <table>report_viewed_product_aggregated_yearly</table>
                </viewed_aggregated_yearly>
            </entities>
        </reports_resource>
    </models>

So I searched the code base for reports/viewed_product_index to see if I can find a ->save() going on somewhere but that didn't seem to lead me any where.

Any thoughts on how to go about finding where this happens?

2 Answers 2

1

You assume that someone had stripped out the code which calling this.

  • This might be a modification in the core (app/code/core) - so I suggest to diff your code against the original Magento code

  • Also the code could be removed by a class overwrite in an extension: Disable all extensions and see if the problem still persists. Then enable them step by step.

1
  • 1
    This is helpful, but it turns out my mistake was that the recently added product excludes the current product from its list. Because I didnt realize this, I thought it was broken and not working. :-x
    – Bryan Ruiz
    Commented Mar 26, 2013 at 9:25
0

I got lucky and found the event in the config.xml which led me to this method in Reports/Model/Event/Observer.php

public function catalogProductView(Varien_Event_Observer $observer)
{
    $productId = $observer->getEvent()->getProduct()->getId();

    Mage::getModel('reports/product_index_viewed')
        ->setProductId($productId)
        ->save()
        ->calculate();

    return $this->_event(Mage_Reports_Model_Event::EVENT_PRODUCT_VIEW, $productId);
}

Now to figure out why that isnt being called!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.