Search code examples
magento

setCustomerid() Fatal error Magento 1.9.2.1


I keep having this problem: Customers can not register, login and logout without an fatal error (enabled debugging).

Fatal error: Call to a member function setCustomerId() on a non-object in ../public_html/app/code/core/Mage/Reports/Model/Product/Index/Abstract.php on line 169

Here is the code snippet from lines 161 - 180:

 /**
 * Calculate count of product index items cache
 *
 * @return Mage_Reports_Model_Product_Index_Abstract
 */
public function calculate()
{
    $collection = $this->getCollection()
        ->setCustomerId($this->getCustomerId())
        ->addIndexFilter();


    Mage::getSingleton('catalog/product_visibility')
        ->addVisibleInSiteFilterToCollection($collection);

    $count = $collection->getSize();
    $this->_getSession()->setData($this->_countCacheKey, $count);
    return $this;
}

What i've done, thanks to answers on similar questions:

  • Cookie settings.
  • Disabled (all) modules, one by one. By xml, admin backend and deleting. Also checked if there were any updates (there were not).
  • Refreshed cache, deleted cache, disabled cache (same for sessions)
  • Set Var directory, media, downloader and eventually all folders and files to 777.
  • Set all the correct permissions back again, thanks to magento-cleanup.php.
  • Checked the database on wrong base url's, secured and unsecured.
  • Did a complete app directory rewrite, uploaded from a clean magento installation.
  • Checked the server settings with , no safe modus (do got a basedir open directory)

Also i'm being redirected tot a 404 page within the backend. With a NoRoute URL, after a correct login. I do see and can use everything in the backend, including the navigation menu.

I do use a template and some customisation with plugins / modules. No coding in core files. Not sure what information is needed, so do ask if i have to mention something.

I'm completely lost after 8 hours of struggling. Hope it is something you can help me with.


Solution

  • Judging by the debug of calling the collection, you have either:

    a) the issue with factory and xml (most likely, it the config.xml of some extension). In this case, you should debug the method _getResourceModelFactoryClassName of the core/config model.

    https://www.gyazo.com/e7c8ebb26326ce2f1a3c7c26b43812ea

    OR

    b) the following class is absent: Mage_Reports_Model_Resource_Product_Index_Compared_Collection

    https://www.gyazo.com/9c59119fe4b97889cb81d2e8980b55fa

    You may check that in the getModelInstance method of the model. Please take into account the fact that while debuging via echo/var_dump you won't be able to good results, since these methods are generally called everywhere by different models.

    I'd rather recommend you to start from checking the presence of the following class: Mage_Reports_Model_Resource_Product_Index_Compared_Collection (app/code/core/mage/reports/model/resource/product/index/compared/collection.php).

    Next, I'd check the presence of model rewrites in the (Mage_Reports) extension + check all recently installed extensions/ implemented changes in config.xml files of these modules.

    Hope it helps.