Magento category tree does not affect category editing and product editing

I am using magento 1.5 and have a weird problem on the category edit and product edit page in admin, the subcategory tree for one category doesn’t show that I wrote my own code to find a subcategory for that particular category and it doesn’t show any subcategory using this one code, but when I checked in the database all subcategories for this category are available.

in simple words, the subcategory tree for one category is not shown in the edit category and the product edit page in admin.

Thanks, Jeet

+3


source to share


4 answers


I can assure you that Zachary Schassler's solution works great in 1.7.0.2. I am just posting so they can help with future questions.

1- I got a problem after I removed a lot of products from the Root category using Catalog / Category Management and deselecting products in the Product Category tab.

2- Template type was Hardware and inside I had several subcategories, the "+" extension sign just disappeared and like all subcategories in the backend, everything is fine in the interface.

3. As Zachary Schessler said and looking in the database for the Hardware category id , the "children_count" column in "catalog_category_entity" I had the value "-20".



4- Edited the value to "20" and everything was fine again in the backend.

Note. This also happened to me once when I moved a subcategory from one category and moved it to another category.

Hooray!

+4


source


Check the column children_count

in catalog_category_entity

. If you had the problem I was doing on 1.6 you probably have negative values.

If so, try this:

UPDATE catalog_category_entity SET children_count = "1" WHERE children_count < 0;

      



It didn't have any side effects when I used it a few months ago. Though, ideally, you would like to calculate children_count

and set it correctly.

edit: I had a problem with wrong levels too. If you imported all of your products, the levels may have received incorrect values. If you have sandbox installed, try this:

    $categories = Mage::getModel('catalog/category')->getCollection();

    foreach ($categories as $category) {
        $category = $category->load($category->getId());

        $path = $category->getPath();

        $levels = explode('/', $path);

        if (is_array($levels) && count($levels)) {
            $category->setLevel(count($levels));
        }

        $resource = Mage::getSingleton('core/resource');

        /**
         * Category save handler doesn't save level when using
         * the API. Use hard query instead.
         */
        $writeConnection = $resource->getConnection('core_write');
        $writeConnection->query('UPDATE catalog_category_entity SET level = ' . $category->getLevel() . ' WHERE entity_id = ' . $category->getId());
    }

      

+7


source


Here is the SQL statement to update all child accounts if they stop syncing with moving categories. Had this problem occurred for us when the server crashed halfway through moving a category inside another.

UPDATE catalog_category_entity a
    INNER JOIN
    (SELECT  parent_id, count(entity_id) totalChildren
       FROM    catalog_category_entity
      GROUP   BY parent_id) b ON a.entity_id=b.parent_id
SET a.children_count = b.totalChildren;

      

+1


source


Update these two queries

UPDATE catalog_category_entity SET level =
(SELECT LENGTH(path)-LENGTH(REPLACE(path,'/','')) AS tmpl
FROM (SELECT * FROM catalog_category_entity) AS table1
WHERE catalog_category_entity.entity_id = table1.entity_id);

      

and

UPDATE catalog_category_entity SET children_count =
(SELECT COUNT(*) FROM
(SELECT * FROM catalog_category_entity) AS table2
WHERE path LIKE
CONCAT(catalog_category_entity.path,"/%"));

      

+1


source







All Articles