【发布时间】:2014-05-11 08:24:59
【问题描述】:
我正在尝试在我的表中插入数据,但总是出现此错误
致命错误:调用未定义的方法 UltimoValue_Warranty_Model_Mysql4_Warranty_Collection::setData() /var/www/magento.dev/app/code/community/UltimoValue/Warranty/controllers/IndexController.php 第 17 行
这是IndexController中的保存代码
public function saveAction()
{
$warrantiesCollection = Mage::getModel('warranty/warranty')->getCollection();
$post = $this->getRequest()->getPost();
if(isset($post['order_number']) && isset($post['save'])) {
try {
$warrantiesCollection->setData('id', null);
$warrantiesCollection->setData('first_name', $post['first_name']);
$warrantiesCollection->setData('last_name', $post['last_name']);
$warrantiesCollection->setData('order_number', $post['order_number']);
$warrantiesCollection->setData('tablet_serial_number', $post['tablet_serial_number']);
$warrantiesCollection->setData('date_purchased', $post['date_purchased']);
$warrantiesCollection->save();
} catch(Exception $e) {
echo $e->getMessage(), "\n";
}
header("Location: " . $_SERVER['HTTP_ORIGIN'] . "/index.php/warranty/index/thankyou/");
exit();
}
}
当我使用 getData - 一切都好...
我做错了什么?
【问题讨论】:
标签: magento magento-1.7 magento-1.8