3

my problem is that viewed products are not working for guest users. After some hours of research I found out that the VisitorId is not generated. Then I found out that Mage_Log is responsible for this. Especially I'm talking about some Mage_Log observer that is not triggered:

app/code/core/Mage/Log/Model/Visitor.php

/**
 * Initialization visitor information by request
 *
 * Used in event "controller_action_predispatch"
 *
 * @param   Varien_Event_Observer $observer
 * @return  Mage_Log_Model_Visitor
 */
public function initByRequest($observer)
{
    if ($this->_skipRequestLogging || $this->isModuleIgnored($observer)) {
        return $this;
    }

    $this->setData($this->_session->getVisitorData());

    $visitorId = $this->getId();
    if (!$visitorId) {
        $this->initServerData();
        $this->setFirstVisitAt(now());
        $this->setIsNewVisitor(true);
        $this->save();
    }
    if (!$visitorId || $this->_isVisitorSessionNew()) {
        Mage::dispatchEvent('visitor_init', array('visitor' => $this));
    }
    return $this;
}

Which is defined here: app/code/core/Mage/Log/etc/config.xml

<frontend>
    <events>
        <controller_action_predispatch>
            <observers>
                <log>
                    <class>log/visitor</class>
                    <method>initByRequest</method>
                </log>
            </observers>
        </controller_action_predispatch>

But since this is some Magento default stuff, I have no idea how to debug this. All I got so far is that controller_action_predispatch is triggered and <log> is not overwritten / used by some code/community/ or code/local/ module.

Any help?

  • What is your issue exaclty ? you want to display logs ? – PЯINCƏ Jul 3 '17 at 9:07
  • @Prince First sentence: "my problem is that viewed products are not working for guest users" - so I want to display viewed products which are by default at the right/left catalog sidebar. For example <block type="reports/product_viewed" before="right.permanent.callout" name="left.reports.product.viewed" template="reports/product_viewed.phtml" /> – Morgy Jul 3 '17 at 9:51
  • You want to display this block in the right or left side bar of your category page ? – PЯINCƏ Jul 3 '17 at 9:54
  • Actually it doesn't matter where I want to display it - it doesn't work anywhere. – Morgy Jul 4 '17 at 10:03
0

Check store configuration System > Configuration > Advanced > System > Log

Check store configuration System > Configuration > Advanced > System > Log

  • Thanks for your answer, but that was acutally my problem in the first place. I set the log to "Yes" or "Visitors only" and the issue of my initial post occurs. – Morgy Jul 3 '17 at 8:48

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.