我在 Magento 中手动创建评论,并试图找出如何添加评分信息?我可以毫无问题地添加评论,但我在评分值(星级值)上苦苦挣扎。我有一个看起来像这样的数组: array("Price"=>80, "Value"=>60, "Quality"=>60);
如何将其添加到星级系统和总结评级?
谢谢。
好的,这就是我到目前为止所拥有的:这增加了一条评论:
$review->setEntityPkValue(23);//product id
$review->setStatusId(1);
$review->setTitle("title");
$review->setDetail("detail");
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE));
$review->setStoreId(Mage::app()->getStore()->getId());
$review->setStatusId(1); //approved
$review->setNickname("Me");
$review->setReviewId($review->getId());
$review->setStores(array(Mage::app()->getStore()->getId()));
$review->save();
$review->aggregate();
这增加了评论的评级<-我被困在这里!
// this is some test code to add the rating review
$rating[0]['Price'] = 80;
$rating[0]['Value'] = 100;
$rating[0]['Quality'] = 80;
$product_id = 23;
$review_id = 631;
foreach ($rating as $ratingId => $optionId) {
// This is the bit where it all seems to go wrong!:
Mage::getModel('rating/rating')
->setRatingId(1)
->setReviewId($review_id)
->addOptionVote($val, $product_id);
}
谢谢!