我正在使用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/