0

I updated yesterday to 1.9 CE and now my category pages I get this fatal error:

Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Category_Flat_Collection::joinUrlRewrite() in /home/senorehe/public_html/app/code/local/Mage/Catalog/Block/Navigation.php on line 155

This is the section it is referring to

public function getCurrentChildCategories()
   {
        $layer = Mage::getSingleton('catalog/layer');
        $category   = $layer->getCurrentCategory();
        /* @var $category Mage_Catalog_Model_Category */
        $collection = Mage::getModel('catalog/category')->getCollection();
        /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
        $collection->addAttributeToSelect('url_key')
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('is_anchor')
            ->addAttributeToSelect('image') 
            ->addAttributeToFilter('is_active', 1)
            ->addIdFilter($category->getChildren())
            ->setOrder('position', 'ASC')
line 155        ->joinUrlRewrite()
            ->load();

        $productCollection = Mage::getResourceModel('catalog/product_collection');
        $layer->prepareProductCollection($productCollection);
        $productCollection->addCountToCategories($collection);
        return $collection;
    } 

I have tried reindexing the URL, flushing my mage_core_url_rewrite then reindexing. But nothing had worked so far.

Can anybody help me with this?

3
  • Just a prompt idea: did you reindex all your data after the update? Jun 3, 2014 at 10:36
  • yea and everything was working fine until about an hour ago
    – Adam Allen
    Jun 3, 2014 at 10:37
  • Ensure you have no duplicate url_keys, you can use this query to check. SELECT url_key, COUNT(url_key) AS NumOccurrences FROM catalog_product_flat_1 GROUP BY url_key HAVING ( COUNT(url_key) > 1 ); And make sure you read the upgrade docs Jun 3, 2014 at 11:08

3 Answers 3

3

I have changed ->joinUrlRewrite() into ->addUrlRewriteToResult(). This has worked for me.

1
  • Any idea why that worked? I see the difference between the two function. Is the category flat still working as intended? Jan 15, 2018 at 0:12
1

I fixed the problem, for some reason when I disabled the flat catalog product and flat catalog category. The problem went away. I don't understand the fix but it worked.

3
  • If your store has many products, it's a good practice to keep flat category enabled. Mar 27, 2015 at 14:03
  • I see the said a lot of places but why is that?
    – Adam Allen
    Mar 27, 2015 at 14:18
  • In my case it looks like to be a reindexing problem while we have many API requests. We are trying to figure out. Mar 27, 2015 at 17:56
0

It's a strange answer, but try checking your cpu load. I had a problem like this when cleanned the entire cache of a store.

It took some hours to get back to normal with no changes in config or code.

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.