magento数据添加
1.第一种方法是一个字段一个字段地添加!
$record = Mage::getModel('warehouse/record');
$record->addData($postData);
$record->setData('batch_id', $batch->getId());
$record->setData('upc', $batch->getData('upc'));
$record->setData('type', Bf170_Warehouse_Model_Record::TYPE_ADJUSTMENT);
$record->setData('status', Bf170_Warehouse_Model_Record::STATUS_COMPLETE);
$record->save();
2用数组添加一条数据:
$data=array(
'product_id'=>4,
'inventory_ticket_id'=>4,
'product_name'=>'裤子',
'qty'=>50,
'type'=>100,
'description'=>'生活上是人民的生活',
'internal_comment'=>'发奖啦说法叫老师说服了',
'status'=>800
);
$model = Mage::getModel('fulfillment/inventory_ticket')->setData($data);
try{
$insertId = $model ->save()->getId();
echo '数据加入成功'.$insertId;
}catch(Exception $e){
echo $e->getMessage();
}