2

Whenever i access product page from front-end as guest user then visitor_id is saving null in report_viewed_product_index table?

2 Answers 2

0

Magento is checking Request safety that can be used to identify if current application request is safe (does not modify state) or not.

Magento prevent saving Visitor for safe methods, e.g. GET request

It means that for GET request magento is not setting visitor_id in that table.

You can check this function in below file.

vendor/magento/framework/App/Request/Http.php

public function isSafeMethod()
{
    if ($this->isSafeMethod === null) {
        if (isset($_SERVER['REQUEST_METHOD']) && (in_array($_SERVER['REQUEST_METHOD'], $this->safeRequestTypes))) {
            $this->isSafeMethod = true;
        } else {
            $this->isSafeMethod = false;
        }
    }
    return $this->isSafeMethod;
}

And you can check this observer as well for more information

vendor/magento/module-reports/Observer/CatalogProductViewObserver.php

Hope this will help you!!

1
  • The visitor must do any form submit like add to compare, newsletter subscribe etc., So then data added to customer_visitor table Jul 25, 2020 at 13:40
0

Change The Deploy mode from Developer To Production

using Command

php bin/magento deploy:mode:set production
1
  • after switching to production mode also not working Jul 25, 2020 at 13:07

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.