Magento 类别树未在类别编辑和产品编辑中显示

标签 magento

我正在使用magento 1.5,并且在类别编辑和产品编辑页面中遇到奇怪的问题 管理员,一个类别的子类别树没有显示我已经编写了自定义代码来查找该特定类别的子类别,并且它没有显示使用该代码的任何子类别,但是当我在数据库中检查了该特定类别的所有子类别时可用。

简单来说,一个类别的子类别树不会显示在管理中的类别编辑和产品编辑页面中。

谢谢, 杰特

最佳答案

检查 catalog_category_entity 中的 children_count 列。如果您遇到我在 1.6 上遇到的问题,您可能会遇到负值。

如果是这种情况,请尝试以下操作:

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

我几个月前使用它时没有任何副作用。不过,理想情况下您希望计算 children_count 并正确设置它。

编辑:我也遇到过同样的问题,级别不正确。如果您导入了所有产品,则级别可能会收到不正确的值。如果您有沙箱设置,请尝试以下操作:

    $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());
    }

关于Magento 类别树未在类别编辑和产品编辑中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9993934/

相关文章:

php - 如何删除 Magento 中所有产品的所有自定义选项

javascript - 如何在 dropzone.js 中显示上传进度百分比

Magento 产品属性获取值

mysql - 从子查询插入

sql - 在 Magento 中实现 SQL 函数 having()

magento - 如何以编程方式比较 magento 版本?

mysql - Magento 在查询删除 50000 个产品时失去与 mysql 服务器的连接

magento - 在产品集合上使用 Magento 的资源迭代器模型

php - 如何从订单中获取 CustomerName?

php - 使用 Magento 时,接近开发环境的好方法是什么?