使用Mageneto API新增一个分类
时间:2016-10-20 14:10来源:未知 作者:好模板 点击:次
使用Mageneto API新增一个分类, 在$MAGENTO_INSTALLED_DIR目录下建立add.php,内容如下: Php代码 ?php //initializemagentoenvironmentfordefaultstore require_once app/Mage.php ; Mage::app( default ); //getanewcategoryobject
使用Mageneto API新增一个分类,在$MAGENTO_INSTALLED_DIR目录下建立add.php,内容如下:
-
<?php
-
-
require_once 'app/Mage.php';
-
Mage::app('default');
-
-
-
$category = Mage::getModel('catalog/category');
-
$category->setStoreId(0);
-
-
$id = $category->getId();
-
-
if ($id) {
-
$category->load($id);
-
}
-
-
$general['name'] = "Cars";
-
$general['path'] = "1/2";
-
$general['description'] = "Great new cars";
-
$general['meta_title'] = "Cars";
-
$general['meta_keywords'] = "car, automobile";
-
$general['meta_description'] = "Some description to be found by meta search robots.";
-
$general['landing_page'] = "";
-
$general['display_mode'] = "PRODUCTS_AND_PAGE";
-
$general['is_active'] = 1;
-
$general['is_anchor'] = 0;
-
$general['url_key'] = "cars";
-
$general['image'] = "cars.jpg";
-
-
-
$category->addData($general);
-
-
try {
-
$category->save();
-
echo "Success! Id: ".$category->getId();
-
}
-
catch (Exception $e){
-
echo $e->getMessage();
-
}
-
?>
(责任编辑:好模板) |
------分隔线----------------------------