我正在使用magento 1.5并且在admin中的类别编辑和产品编辑页面中有奇怪的问题,一个类别的子类别树未显示我已编写自定义代码以查找该特定类别的子类别且未显示任何子类别使用该代码,但是当我在数据库中检查了该特定类别的所有子类别时.
简单来说,一个类别的子类别树没有显示在管理员的类别编辑和产品编辑页面中.
谢谢,Jeet
检查您的children_count专栏catalog_category_entity.如果您遇到我在1.6上遇到的问题,那么您可能会有负值.
如果是这种情况,请尝试以下方法:
UPDATE catalog_category_entity SET children_count = "1" WHERE children_count < 0;
Run Code Online (Sandbox Code Playgroud)
几个月前我用它时没有任何不良影响.虽然,理想情况下,您需要计算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());
}
Run Code Online (Sandbox Code Playgroud)
小智 5
我可以向您保证,Zachary Schuessler解决方案可以在1.7.0.2中完美运行。我刚刚发布,因此可以解决以后的问题。
1-我使用“目录/管理类别”从“根”类别下删除了很多产品并在“类别产品”选项卡中取消选择产品后,遇到了这个问题。
2-模式类别为硬件,并且在我内部有几个子类别,扩展“ +”号消失了,因此后端的所有子类别都很好,前端也很好。
3-就像Zachary Schuessler所说的,并在“ 硬件类别ID”中查看数据库时,“ catalog_category_entity”中的“ children_count”列的值为“ -20”。
4-将值编辑为“ 20”,后端的一切都很好。
注意:当我从一个类别中移出一个子类别并将其移至其他不同类别中时,这也发生了。
干杯!
| 归档时间: |
|
| 查看次数: |
4294 次 |
| 最近记录: |