3

The Magento compare list feature only works, when the log_* tables are being filled. If they are not, the compare list is global, which means, whenever a customer adds to the list, every other customer can see that recently added item. I disabled (and cant enable) this feature by putting this in my local.xml:

<controller_action_predispatch> 
    <observers><log><type>disabled</type></log></observers> 
</controller_action_predispatch> 
<controller_action_postdispatch> 
    <observers><log><type>disabled</type></log></observers> 
</controller_action_postdispatch> 

Removing this makes the compare list work right away. The question is, is there a workaround for that? Is there a way to make the compare list work and not fill the log_* tables?

Thanks!

1

Sadly the compare items are tightly linked to the visitor information.

The table catalog_compare_item has a column for visitor_id which when you disable the observers mentioned in your question, is set to 0 and so all visitors can see these items.

When you add an item to the compare list the visitor is linked into that item.

Mage_Catalog_Model_Product_Compare_List::addProduct calls the protected function _addVisitorToItem which gets the visitor id set from the log/visitor and attaches this to the item, as well as the customer id when you are logged in.

protected function _addVisitorToItem($item)
{
    $item->addVisitorId(Mage::getSingleton('log/visitor')->getId());
    if (Mage::getSingleton('customer/session')->isLoggedIn()) {
        $item->addCustomerData(Mage::getSingleton('customer/session')->getCustomer());
    }

    return $this;
}

Without limiting the compare functionality to logged in customers only I cannot see a way around filling these log tables as Magento needs to know what visitor is actually requesting the items to be compared.

1

This is an old question, but for anybody who still stumbles across this wanted to point out a solution that Yireo developed. By overriding the getId function in Mage_Log_Model_Visitor with a fake user ID that is based on the session ID, functionality that depends on the log user ID continues to work:

// Return a bogus visitor-ID that is not logged at all, but used in various buggy Magento parts 
return abs(crc32(Mage::getModel('core/session')->getSessionId()));

See source here: https://github.com/yireo/Yireo_DisableLog/blob/master/source/app/code/community/Yireo/DisableLog/Model/Rewrite/Log/Visitor.php#L57

Note that you may be best off using their entire extension, as it provides additional related functionality to support disabling customer logging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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