有的时候我们添加新品会采用 表格批量上传的方式,也会同时创建新的分类。 
这就会导致,查看某个单品时,分类是这样的: 
正常应该是这样的: 
调试发现 后台数据 分类表 
catalog_category_entity 的 children_count 存在负数 
如果启用了索引,那么 catalog_category_flat_sotre_1 这种表中字段 children_count 也存在负数
产生原因大致是因为:通过 api 创建分类导致的,具体代码没有去追踪。
修复方法: 执行SQL
DROP TABLE IF EXISTS `catalog_category_entity_tmp`;
CREATE TABLE catalog_category_entity_tmp LIKE catalog_category_entity;
INSERT INTO catalog_category_entity_tmp SELECT * FROM catalog_category_entity;
UPDATE catalog_category_entity cce
SET children_count =
(
SELECT count(cce2.entity_id)-1 as children_county
FROM catalog_category_entity_tmp cce2
WHERE PATH LIKE CONCAT(cce.path,'%')
);
DROP TABLE catalog_category_entity_tmp;
然后 刷新分类索引 即可
                  
                  
                  
                  
                            
本文介绍了一种解决Magento后台分类计数出现负数的问题的方法,通过重建临时表并更新分类计数来修复此问题。
          
      
          
                
                
                
                
              
                
                
                
                
                
              
                
                
              
            
                  
					3735
					
被折叠的  条评论
		 为什么被折叠?
		 
		 
		
    
  
    
  
            


            