Question

Problem

I'm having a strange issue with my url_key field reverting to NULL on my catalog_category_flat_store_1 table following a reindex, but only on categories that I have created since enabling the Flat Category index.

As a result, when I attempt to fetch the category via url_key as so:

    $category = Mage::getModel('catalog/category')
        ->getCollection()
        ->addAttributeToFilter('url_key', 'my-url-key')
        ->getFirstItem();

    $category->load($category->getId());

I am unable to do so. If I go back and re-save the category, the url_key is added back to the flat table and I'm able to retrieve the category.

Has anyone else had this problem or am I missing something regarding the way flat tables operate?

What I've Found/Tried

Because the value would initially save and then disappear, I examined the catalog_category_entity files. Here's what I found:

  1. The url_key value is saving properly in catalog_category_entity_url_key
  2. However, neither the url_key nor the url_path attributes are saving in catalog_category_entity_varchar as they were with categories that I created before enabling Flat tables.
  3. If I manually add the url_key to catalog_category_entity_varchar, values are preserved and copied to catalog_category_flat_store_1 as expected when reindexing.

I have tried disabling the flat tables and while the url_key value is still not saved to catalog_category_entity_varchar, I am able to category via the url_key using my code above.

FWIW, I'm using Enterprise 1.13.

Update

I used MAGMI to import my products/categories; because CE uses varchar attributes rather than a separate table as the newer versions of enterprise do, this may be a non-issue. I created a fresh install of Enterprise and added the categories manually. I'm noticing that the url_key and url_path fields are not copied over to the flat tables anyway.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top