We have a large number of categories that were created with code and had a server related error (long since fixed) that resulted in the parent category not being properly assigned.

These categories exist in the catalog_category_entity database table, but show a parent_id of 0 (our default category is 2, there is no entity_id of 0).

I've attempted to use the standard functions to assign a parent category to these, however using:

$category = Mage::getModel( 'catalog/category' )->load($id);

I get an error message of "Call to a member function getModelInstance() on null in {path}/app/Mage.php on line 463" This is being generated simply by attempting to load the category that needs to be fixed.

I know I could create a new category, but since there are a number of subcategories already assigned to this missing category and numerous products, I'd prefer to fix this programmatically to save a lot of manual work.

Any suggestions on a fix here?

  • Do you want to move category or create new category? – Sunil Patel Oct 27 '17 at 16:42
  • The existing category should be retained and moved to the correct parent. Creating a new category is not ideal as mentioned above as there are already numerous subcategories and products that would have to be updated if a new category is created. (And, since we can't seem to load this category, not sure how we would delete it even) – Mark Oct 27 '17 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.