Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hole punching does not load on product pages #2

Open
bslinger opened this issue Jul 11, 2012 · 1 comment
Open

Hole punching does not load on product pages #2

bslinger opened this issue Jul 11, 2012 · 1 comment

Comments

@bslinger
Copy link

Magento 1.6.2.0

There is an issue loading the hole punched data on product pages which seems to be due to this code in HoleController.php:

 if (array_key_exists('pid', $data)) {


        $product_index = Mage::getModel('reports/product_index_viewed')->getCollection()
                    ->addFieldToFilter('store_id',   array('eq' => Mage::app()->getStore()->getId()))
                    ->addFieldToFilter('product_id', array('eq' => $data['pid']));

        if ($session->isLoggedIn()) {

            $product_index->addFieldToFilter('customer_id', array('eq' => $session->getCustomerId()));

            if (count($product_index) < 1)
                            Mage::getModel('reports/product_index_viewed')
                                        ->setCustomerId($session->getCustomerId())
                                        ->setProductId($data['pid'])
                                        ->setStoreId(Mage::app()->getStore()->getId())
                                        ->save()
                                        ->calculate();

        } else {

            $product_index->addFieldToFilter('visitor_id', array('eq' => Mage::getSingleton('log/visitor')->getId()));


            if (count($product_index) < 1)
            Mage::getModel('reports/product_index_viewed')
                    ->setVisitorId(Mage::getSingleton('log/visitor')->getId())
                    ->setCustomerId(null)
                        ->setProductId($data['pid'])            
                    ->setStoreId(Mage::app()->getStore()->getId())
                        ->save()
                        ->calculate(); 
        }

    }

It seems to stem from the fact that the reports/product_index_viewed table extends from the catalog/product collection and so the addFieldToFilter functions don't work as expected. The error I am receiving is as follows:

Call to a member function getBackend() on a non-object in /home/sites/magento.directshop.com.au/docs/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 822

For now I've commented out the code as it just seems to relate to counting product views for cached products, but it would be nice to have a solution. I noticed somebody else was having the same problem here: http://www.magentocommerce.com/boards/viewthread/275766/P30/#t391771

@sloth456
Copy link

Thanks for this fix! Works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants