Here is my code:
if ($user->isLoggedIn()) {
$userinfo = $user->getCustomer();
$userid = $userinfo->getId();
$username = $userinfo->getEmail();
$userfullname = $userinfo->getName();
Mage::log(
"{$userid},{$username},{$userfullname}\n",
null,
'product-updates.log'
);
$up_id = intval($userinfo->getId().$product->getId()."");
$data = array(
'click_time' => date("Y-m-d H:i:s"),
'product_id' => $product->getId(),
'product_name' => $product->getName(),
'product_category' => $category,
'product_value' => $product->getPrice(),
'user_id' => $userid,
'username' => $username,
'fullname' => $userfullname,
'firstname' => $userinfo->getFirstname(),
'middlename' => $userinfo->getMiddlename(),
'lastname' => $userinfo->getLastname(),
'register_time' => $userinfo->getCreatedAt(),
'up_id' => $up_id
);
$model = Mage::getModel('modulename/modelName')->load($up_id,'up_id')->addData($data);
try {
$insertId = $model->save()->getId();
} catch (Exception $e){
}
}
Points:
-> product-updates.log file logs everything correctly with username (email) and full name of the customer.
-> on saving to database, product_id , and all fields successfully save except for customer name, customer middle, first and last name and register_time.
-> No errors in system.log, no exceptions in exception.log
-> Logs are enabled and cache is disabled.
Problem:
So problem is that I am not able to save customer name, even though it is being displayed in the product-log file correctly. Also there are no syntax errors or any other error because other fields are getting saved to the database.
Edit: My database structure:
username varchar(200)
fullname varchar(200)
firstname varchar(200)
middlename varchar(200)
lastname varchar(200)
Mage::getModel('modulename/modelName')->load($up_id,'up_id')actually loading a record? Also I see a lot more fields in the data array vs your table structure