Php Magento产品编辑屏幕,未显示类别

Php Magento产品编辑屏幕,未显示类别,php,magento,Php,Magento,我有一个magento商店(1.5.1.0版),有很多类别,这些类别是使用以下类别复制脚本添加的- <?php if(!is_numeric($_GET['id']))die('Please specify a category ID'); $catId = $_GET['id']; $xml = simplexml_load_file('app/etc/local.xml'); $host = $xml->global->resources->default_set

我有一个magento商店(1.5.1.0版),有很多类别,这些类别是使用以下类别复制脚本添加的-

<?php
if(!is_numeric($_GET['id']))die('Please specify a category ID');

$catId = $_GET['id'];

$xml = simplexml_load_file('app/etc/local.xml');
$host = $xml->global->resources->default_setup->connection->host;
$username = $xml->global->resources->default_setup->connection->username;
$password = $xml->global->resources->default_setup->connection->password;
$dbname = $xml->global->resources->default_setup->connection->dbname; 
$res = mysql_pconnect($host, $username, $password);   
mysql_select_db($dbname);

$catsDone = 0;
duplicate_entity($catId);
echo $catsDone . ' Categories duplicated.';

function duplicate_entity($id, $parent_id = null){
    global $catsDone;


    // Grab category to copy
    $sql = "SELECT * FROM catalog_category_entity WHERE entity_id = " . $id;
    $query_entity = mysql_query($sql);

    $entity = mysql_fetch_object($query_entity);

    if(!$parent_id)$parent_id = $entity->parent_id;

    mysql_query("INSERT INTO catalog_category_entity (entity_type_id, attribute_set_id, parent_id, created_at, updated_at, path, position, level, children_count)
                        VALUES ({$entity->entity_type_id}, {$entity->attribute_set_id}, {$parent_id}, NOW(), NOW(), '', {$entity->position}, {$entity->level}, {$entity->children_count})");
    $newEntityId = mysql_insert_id();

    $query = mysql_query("SELECT path FROM catalog_category_entity WHERE entity_id = " . $parent_id);
    $parent = mysql_fetch_object($query);
    $path = $parent->path . '/' . $newEntityId;

    mysql_query("UPDATE catalog_category_entity SET path='". $path."' WHERE entity_id=". $newEntityId);

    foreach(array('datetime', 'decimal', 'int', 'text', 'varchar') as $dataType){
        $sql = "SELECT * FROM catalog_category_entity_".$dataType."
                WHERE entity_id=" . $entity->entity_id;
                //die($sql);
        $query = mysql_query($sql);
        while ($value = mysql_fetch_object($query)){
            mysql_query("INSERT INTO catalog_category_entity_".$dataType." (entity_type_id, attribute_id, store_id, entity_id, value)
                            VALUES ({$value->entity_type_id}, {$value->attribute_id}, {$value->store_id}, {$newEntityId}, '{$value->value}')");
        }
    }

    $sql = "SELECT entity_id FROM catalog_category_entity WHERE parent_id = " . $id;
    $query = mysql_query($sql);

    while ($entity = mysql_fetch_object($query)){
        duplicate_entity($entity->entity_id, $newEntityId);
    }
    $catsDone++;
}
?>
全局->资源->默认设置->连接->主机;
$username=$xml->global->resources->default\u setup->connection->username;
$password=$xml->global->resources->default\u setup->connection->password;
$dbname=$xml->global->resources->default\u setup->connection->dbname;
$res=mysql\u pconnect($host、$username、$password);
mysql\u select\u db($dbname);
$catsDone=0;
重复实体($catId);
回声$catsDone。”类别重复';
函数重复\u实体($id,$parent\u id=null){
全球$catsDone;
//抓取要复制的类别
$sql=“从目录\类别\实体中选择*,其中实体\ id=”.$id;
$query\u entity=mysql\u query($sql);
$entity=mysql\u fetch\u对象($query\u entity);
如果(!$parent\u id)$parent\u id=$entity->parent\u id;
mysql查询(“插入目录\类别\实体(实体\类型\ id、属性\集\ id、父\ id、创建\处、更新\处、路径、位置、级别、子\计数)
值({$entity->entity_type_id},{$entity->attribute_set_id},{$parent_id},NOW(),NOW(),“,{$entity->position},{$entity->level},{$entity->children_count}”);
$newEntityId=mysql\u insert\u id();
$query=mysql\u query(“从目录\u类别\u实体中选择路径,其中实体\u id=“.$parent\u id”);
$parent=mysql\u fetch\u对象($query);
$path=$parent->path.'/'.$newEntityId;
mysql_查询(“更新目录_类别_实体集路径=”“$path.”其中实体_id=“.$newEntityId”);
foreach(数组('datetime','decimal','int','text','varchar')作为$dataType){
$sql=“从目录\类别\实体\中选择*。$dataType。”
其中entity_id=“.$entity->entity_id;
//死亡($sql);
$query=mysql\u查询($sql);
while($value=mysql\u fetch\u object($query)){
mysql查询(“插入目录\类别\实体\数据类型”。$dataType.”(实体\类型\ id、属性\ id、存储\ id、实体\ id、值)
值({$value->entity_type_id},{$value->attribute_id},{$value->store_id},{$newEntityId},{$value->value}');
}
}
$sql=“从目录\u类别\u实体中选择实体\u id,其中父实体\u id=”.$id;
$query=mysql\u查询($sql);
while($entity=mysql\u fetch\u object($query)){
重复的实体($entity->entity\u id,$newEntityId);
}
$catsDone++;
}
?>
类别在类别树、前端等中显示良好,但在类别编辑选项卡上的产品编辑屏幕上,我只能看到默认类别?

目录类别实体中的“子项计数”列可能不正确。我也有同样的问题

运行以下命令:

UPDATE catalog_category_entity SET children_count = "1" WHERE children_count < 1;
updatecatalog\u category\u entity SET children\u count=“1”,其中children\u count<1;

参考/更多信息:

您的导入脚本未涵盖“目录\类别\实体”表的所有表列。基本上,您忘记了更新“level”和“children\u count”行


哦,我忘了。扎卡里的剧本也很糟糕。它并没有解决这个问题,只是屏蔽它,让JavaScript来“咀嚼”它。我链接的脚本将正确设置所有内容。

看起来像是javascript问题,您在firebug控制台中看到任何javascript错误吗?我理解我的解决方案如何“掩盖”问题(虽然我的解决方案不会导致任何问题),但您能解释一下javascript“咬碎”的部分吗?不知道这意味着什么,我真的很好奇。