Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过脚本导入magento中的类别_Php_Magento_Categories - Fatal编程技术网

Php 通过脚本导入magento中的类别

Php 通过脚本导入magento中的类别,php,magento,categories,Php,Magento,Categories,你好,我刚刚开始学习magento。现在我正试图通过脚本导入magento中的类别 我的magento代码看起来像 <?php require_once 'businessclasses.php'; define('MAGENTO', realpath(dirname(__FILE__))); require_once MAGENTO . '/app/Mage.php'; umask(0); $count = 0; echo "<pr

你好,我刚刚开始学习magento。现在我正试图通过脚本导入magento中的类别

我的magento代码看起来像

<?php
    require_once 'businessclasses.php';
    define('MAGENTO', realpath(dirname(__FILE__)));
    require_once MAGENTO . '/app/Mage.php';
    umask(0);
    $count = 0;

    echo "<pre>";
    $data= new getCSV();
    $rows=$data->getRootCategories(); // Gets the list of root categories.

    foreach($rows as $row) {
        echo $categoryName = $row['d']; // Name of Category

        // Create category object
        $category = Mage::getModel('catalog/category');
        $category->setStoreId(1); // 'US-Store' store is assigned to this category

        $rootCategory['name'] = $categoryName;
        $rootCategory['path'] = "23/25"; // this is the catgeory path
        $rootCategory['display_mode'] = "PRODUCTS";
        $rootCategory['is_active'] = 1;
        $category->addData($rootCategory);

        try {
            $category->save();
            echo $rootCategoryId = $category->getId();
        }
        catch (Exception $e){
            echo $e->getMessage();
        }
    }
?>
打印每个类别(循环)的唯一ID,但当我在管理面板上看到时,它没有显示任何内容。不喜欢导入任何类别

我已经提到过这一点,但它没有帮助


任何帮助都将不胜感激。谢谢。

嘿,伙计们,我有答案了


$rootCategory['path']=“1/23/25”;//这是catgeory路径你自己已经找到了答案。不过,如果有人想找一些其他的分类、产品和其他导入/导出工具,我推荐Magmi,这个很棒的工具帮我节省了很多时间

echo $rootCategoryId = $category->getId();
$rootCategory['path'] = "1/23/25"; // this is the catgeory path  <-- I was giving this path wrong.