我正在尝试以编程方式添加类别。类别很容易创建,但我没有找到添加类别图像的方法。 这是我的代码。
$brand_name = $_POST['brand_name'];
$brand_logo = $_FILES['filename']['name'];
$brand_content = $_POST['brand_content'];
$brand_id = $_POST['brand_id'];
$brand_path = $brand_logo;
$parentId = '35';
$category = new Mage_Catalog_Model_Category();
$category->setName($brand_name);
$category->setUrlKey($brand_name);
$category->setIsActive(1);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(0);
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
$category->setPath($parentCategory->getPath());
$data['display_mode'] = 'PRODUCTS_AND_PAGE';
$data['page_layout'] = 'one_column';
$data['thumbnail'] = $brand_path;
$category->addData($data);
$category->save();
unset($category);
提前致谢
答案 0 :(得分:0)
您已经拥有为您的猫添加图像的部分。它是:
$data['thumbnail'] = $brand_path;
但我确定$ brand_path = $ brand_logo = $ _FILES ['filename'] ['name']包含错误的cat thumbnail参数值。
$ data ['thumbnail']应该包含图像路径,而不仅仅是图像名称。