2

我想先导入与类别相关的数据,然后再导入产品。但是,当我要仅上传类别 csv 文件时,它显示错误“未找到 sku”,当我尝试导入类别和产品 csv 的合并数据时,它正在导入产品但不显示任何类别,并且在产品中显示 0 记录找到并在导入中显示上传成功消息。谁能帮帮我吗。

4

2 回答 2

0

您必须单独导入类别。

将所有信息放入您的 csv 中,然后通过如下自定义脚本:

(在您的 Magento 根文件夹中创建一个脚本目录,并在此位置创建一个 category.php 文件)。

然后您就可以通过访问 yoursite.com/script/category.php 来导入您的类别

您可以在此处找到示例:

http://www.magentoworks.net/import-bulk-category-in-magento

问候,

于 2013-02-05T08:01:46.100 回答
0

请参考我的教程,它使用 magento 脚本创建类别和子类别。

http://www.pearlbells.co.uk/import-the-categories-programmatically/

foreach ($arrResult as $import_category) {
    try {
        if (strtolower($import_category[16]) == 'true') {
            $enabled = 1;
        } else {
            $enabled = 0;
        }

        if ($import_category[1] == 0) {
            $parentId = '2';
        }
        else {
            $parentId = $list[$import_category[1]];
        }

        $category = Mage::getModel('catalog/category');
        $category->setName($import_category[2]);
        $category->setMetaTitle($import_category[2]);
        $category->setIncludeInMenu(1);
        $category->setUrlKey($import_category[10]);
        $category->setDescription(strip_tags($import_category[11]));
        $category->setMetaDescription($import_category[12]);
        $category->setMetaKeywords($import_category[13]);
        $category->setIsActive($enabled);
        $category->setDisplayMode('PRODUCTS');
        $category->setIsAnchor(1); //for active anchor
        $category->setStoreId(Mage::app()->getStore()->getId());
        $parentCategory = Mage::getModel('catalog/category')->load($parentId);
        $category->setPath($parentCategory->getPath());
        $category->setCustomUseParentSettings(true);
        $category->setImage($import_category[6]);
        $category->save();
        $list[$import_category[0]] = $category->getId();
        echo 'Category ' . $category->getName() . ' ' . $category->getId() . ' imported successfully' . PHP_EOL;
    } catch (Exception $e) {
        echo 'Something failed for category ' . $import_category[2] . PHP_EOL;
        print_r($e);
    }
}
于 2016-11-06T01:28:56.860 回答