0

I am trying to add category programatically. Category got created very easily but i am not finding the way to add category image. here is my code.

    $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);

Thanks in advance

4

1 回答 1

0

你已经有了为你的猫添加图像的部分。它的:

$data['thumbnail'] = $brand_path;

但我确定 $brand_path = $brand_logo = $_FILES['filename']['name'] 包含 cat thumbnail 参数的错误值。

$data['thumbnail'] 应该包含图像路径,而不仅仅是图像名称。

于 2012-12-19T11:42:51.053 回答