require_once 'app/Mage.php';
Mage::app();
// IMPORTANT: Set up customer session.
// the rating/option model resource checks the customer session to get the customer ID.
$_session = Mage::getSingleton('customer/session')->setCustomer($_customer)->setCustomerAsLoggedIn($_customer);
// Add Review
$_review = Mage::getModel('review/review');
->setEntityPkValue($_product->getId())
->setStatusId($sc_to_mage_review_status[$row_source_review['Status']])
->setTitle($row_source_review['Title'])
->setDetail($row_source_review['Review'])
->setEntityId(1)
->setStoreId($store)
->setStores(array($store))
->setCustomerId($_customer->getId())
->setNickname($_customer->getFirstname())
->save();
Probable Error within these:
Check last comma of the array
$rating_options = array(
1 => array(1,2,3,4,5), // <== Look at your database table `rating_option` for these vals
2 => array(6,7,8,9,10),
3 => array(11,12,13,14,15)
);
Probable Error within these:
foreach($rating_options as $rating_id => $option_ids):
try {
$_rating = Mage::getModel('rating/rating')
->setRatingId($rating_id)
->setReviewId($_review->getId())
->addOptionVote($option_ids[$rating_value-1],$_product->getId());
} catch (Exception $e) {
die($e->getMessage());
}
endforeach;
Best Answer
You can use this extension
http://www.magentocommerce.com/magento-connect/product-review-import-export.html
This extension allowed to import/export reviews and ratings in csv format from magento dataflow profile .
Or alternatively you can use this code to get ratings of review
This will give you rating collection of review