当我试图添加评论和评分时,我会收到如下错误:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'customer_id' cannot be null, query was: INSERT INTO `rating_option_vote` (`option_id`, `review_id`, `percent`, `value`, `remote_ip`, `remote_ip_long`, `customer_id`, `entity_pk_value`, `rating_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
我的代码:
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
->setEntityPkValue($product->getId())
->setStatusId(Mage_Review_Model_Review::STATUS_APPROVED)
->setCustomerId((int)$customerId)
->setStoreId($storeId)
->setStore(array($storeId))
->save();
$rating=array(1=>1,6=>1,11=>1);
foreach ($rating as $ratingId => $optionId) {
Mage::getModel('rating/rating')
->setCustomerId((int)$customerId)
->setRatingId($ratingId)
->setReviewId($review->getId())
->setCustomerId((int)$customerId)
->addOptionVote($optionId, $review->getEntityPkValue())
// ->save()
;
}
任何帮助表示感谢。