|
I had the same problem and discovered some “stray categories”—ones that referred to parent_ids that did not exist. I ran this query and found several:
SELECT entity_id FROM catalog_category_entity AS cce WHERE parent_id NOT IN (SELECT entity_id FROM catalog_category_entity AS cce2) AND parent_id>0
So what you want to do is write a PHP script to delete out those categories using the ‘category.delete’ API. You could do it manually, but you have to delete from so many tables that you could make a mistake and leave out one. Here’s an example of my query:
// Call SOAP $proxy = new SoapClient('http://www.yoursite.com/magento/api/soap/?wsdl'); $sessionId = $proxy->login('yourlogin', 'password');
// Get all up stray categories mysql_select_db($yourmagentoinfo); $query_rsBadCats = "SELECT entity_id FROM catalog_category_entity AS cce WHERE parent_id NOT IN (SELECT entity_id FROM catalog_category_entity AS cce2) AND parent_id>0 "; $rsBadCats = mysql_query($query_rsBadCats, $magento) or die(mysql_error()); $row_rsBadCats=mysql_fetch_assoc($rsBadCats); do { echo "Deleting ".$row_rsBadCats['entity_id']."<br>"; $allCategories = $proxy->call($sessionId, 'category.delete', $row_rsBadCats['entity_id']); } while ($row_rsBadCats=mysql_fetch_assoc($rsBadCats));
I’m not sure why I had those strays—a lot of adding and deleting categories while I set up the store, probably. Anyway, this query worked for me.
|