0
我想从一个magento商店导出类别并导入到另一个。如何以编程方式向Magento添加类别和类别路径?
以下信息是必须在商店中插入的类别的一部分。
Default Category 2
All Categories 2/30
Electronics 2/30/12
TV & Video 2/30/12/13
我试试以下脚本导入一个类别,但不起作用。该脚本不会导入该类别。
require_once 'app/Mage.php';
Mage::app('default'); // Default or your store view name.
//get a new category object
$category = Mage::getModel('catalog/category');
$category->setStoreId(0); // 0 = default/all store view. If you want to save data for a specific store view, replace 0 by Mage::app()->getStore()->getId().
//if update
if ($id) {
$category->load($id);
}
$general['name'] = "All Categories";
$general['path'] = "2/30"; // catalog path
$general['description'] = "";
$general['meta_title'] = ""; //Page title
$general['meta_keywords'] = "";
$general['meta_description'] = "";
$general['landing_page'] = ""; //has to be created in advance, here comes id
$general['display_mode'] = "PRODUCTS_AND_PAGE"; //static block and the products are shown on the page
$general['is_active'] = 1;
$general['is_anchor'] = 0;
$general['page_layout'] = 'two_columns_left';
$category->addData($general);
try {
$category->save();
echo "Success! Id: ".$category->getId();
}
catch (Exception $e){
echo $e->getMessage();
}
您现在面临哪个错误? – Chiragit007
该类别未插入且脚本已成功完成。 – dido