如何向Magento 1.6添加新产品? 我试过这个: -
$product = Mage::getModel('catalog/product');
$product->setWebsiteIds(array('1'));
$product->setAttributeSetId(4);
$product->setType('Simple');
$product->setName("test");
$product->setDescription('[description]');
$product->setShortDescription('[short_description]');
$product->setPrice($arg_data['price']);
$product->setWeight($arg_data['weight']);
$product->setStatus(1);
$product->setTaxClassId(2);
$product->setCategoryIds($arg_data['category_ids']);
$product->setVisibility(4);
$product->save();
答案 0 :(得分:3)
对于类别,您必须在数组中声明ID,如下所示:
$product->setCategoryIds( array( $arg_data['category_ids'] ) );
多个类别如下:
$product->setCategoryIds( array( 1, 5, 23, 98 ) );