Magento Forum

   
Magent review form Unable to post the review. 
 
muk_t
Sr. Member
 
Total Posts:  222
Joined:  2012-07-24
 

Hi,

I am facing a problem that when a user has filled all the required fields of the review form and submit this form there comes a message Unable to post the review.

I have the following code in ProductController.php file (wamp\www\myproject\app\code\core\Mage\Review\controllers\ProductController.php)

$validate $review->validate();
            if (
$validate === true) {
                
try {
                    $review
->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
                        ->
setEntityPkValue($product->getId())
                        ->
setStatusId(Mage_Review_Model_Review::STATUS_PENDING)
                        ->
setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
                        ->
setStoreId(Mage::app()->getStore()->getId())
                        ->
setStores(array(Mage::app()->getStore()->getId()))
                        ->
save();

                    foreach (
$rating as $ratingId => $optionId{
                        Mage
::getModel('rating/rating')
                        ->
setRatingId($ratingId)
                        ->
setReviewId($review->getId())
                        ->
setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
                        ->
addOptionVote($optionId$product->getId());
                    
}

                    $review
->aggregate();
                    
$session->addSuccess($this->__('Your review has been accepted for moderation.'));
                
}
                
catch (Exception $e)
            
{                
                   $session
->setFormData($data);
                    
$session->addError($this->__('Unable to post the review.'));
                    echo 
$e->getMessage();exit;         
                
}
            }

I wrote this line of code :  echo $e->getMessage();exit;

Now when I submit the review form I get the following error message

“SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`myproject`.`review`, CONSTRAINT `FK_REVIEW_ENTITY_ID_REVIEW_ENTITY_ENTITY_ID` FOREIGN KEY (`entity_id`) REFERENCES `review_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE)”

How to fix this .Please help
Thanks.


Found The solution

There was a problem in the database, there were no default values present in the “review_entity" “review_status” tables.  wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
makotokoganicom
Jr. Member
 
Total Posts:  26
Joined:  2009-11-16
 

Im having the same massage “unable to sumbit review” on the review form.
I didnt understand what you meant by default value in database.
Please give me more detail.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  222
Joined:  2012-07-24
 

Hi

I am attaching screenshots of the tables.
You can see the default values there.If you do not have these values in table then you need to add them.

Hope this works for you.If not contact me .
Thanks

Image Attachments
review_status.pngreview_entity.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
makotokoganicom
Jr. Member
 
Total Posts:  26
Joined:  2009-11-16
 

Dear muk_t
Thanks so much for your answer.  I checked my database and those values are there. I found out that my error is browser issue. I get the error massage when I only use Google Chrome.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top