你好,我剛開始學習magento。現在我試圖通過腳本在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();
}
}
?>
此代碼運行沒有錯誤,也該線
echo $rootCategoryId = $category->getId();
打印唯一的ID爲每個類別(環路),但是當我看到在管理潘內爾它沒有顯示任何東西。像沒有進口的類別。
我已經回答了這個 Question.但它沒有幫助。
任何幫助,將不勝感激。謝謝。