Magento-如何将评级信息添加到评论中
我正在Magento中手动创建评论,并试图了解如何在中添加评级信息?我可以添加评论没有问题,但我正在努力与评级值(星级值)。 我有一个如下所示的数组: 数组(“价格”=>80,“价值”=>60,“质量”=>60) 如何将其添加到星级系统和汇总评级中 谢谢 好的,这就是我目前的情况: 这增加了一项审查:Magento-如何将评级信息添加到评论中,magento,rating,review,Magento,Rating,Review,我正在Magento中手动创建评论,并试图了解如何在中添加评级信息?我可以添加评论没有问题,但我正在努力与评级值(星级值)。 我有一个如下所示的数组: 数组(“价格”=>80,“价值”=>60,“质量”=>60) 如何将其添加到星级系统和汇总评级中 谢谢 好的,这就是我目前的情况: 这增加了一项审查: $review->setEntityPkValue(23);//product id $review->setStatusId(1); $review->setTitle("ti
$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();
这增加了一个评价这对我来说很有效:
public function addReview($ratingarray)
{
$product_id = $ratingarray['product_id'];
$storeid = $ratingarray['store_id'];
$title = $ratingarray['title'];
$customerid = $ratingarray['customer_id'];
$nickname = $ratingarray['nickname'];
$detail = $ratingarray['detail'];
$review = Mage::getModel('review/review');
$review->setEntityPkValue($product_id);
$review->setStatusId(1);
$review->setTitle($title);
$review->setDetail($detail );
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE));
$review->setStoreId($storeid);
$review->setStatusId(1); //approved
$review->setCustomerId($customerid);
$review->setNickname($nickname);
$review->setReviewId($review->getId());
$review->setStores(array($storeid));
$review->save();
$review->aggregate();
//return "success";
$rating_options = $ratingarray['options'];
/*array(
array(1,2,3,4),
array(6,7,8),
array(11,12)
);*/
$row = count($rating_options);
$rating_id = 1;
foreach($rating_options as $key1=>$val1)
{
foreach($val1 as $key2=>$val2)
{
$_rating = Mage::getModel('rating/rating')
->setRatingId($key1)
->setReviewId($review->getId())
->addOptionVote($val2,$product_id );
}
}
return "Success";
}
我称之为=>
$options=array(1=>array(1,2,3,4),2=>array(6,7,8),3=>array(11,12));
$reviewarray=array('customer_-id'=>'21','product_-id'=>'176','store_-id'=>'4','title'=>'Review','nickname'=>'XYZ','detail'=>'Nice product with Life time warrenty','options'=>$options) 不清楚你所说的“手动”是什么意思。您是否正在编写代码来创建评论?寻找你需要做什么来增加评级值?把你做的代码贴出来,你会告诉我更有可能得到答案。嗨,艾伦。谢谢你的回复。是的,我正在编写代码来创建评论并添加评级值(价格、质量、价值等)。我已经编写了创建评论的代码,只是没有添加评分。我现在不在办公桌旁,所以我无法找到我写的代码,但我会在明天可以的时候发布。谢谢,我现在已经把我的代码添加到问题中了。谢谢
public function addReview($ratingarray)
{
$product_id = $ratingarray['product_id'];
$storeid = $ratingarray['store_id'];
$title = $ratingarray['title'];
$customerid = $ratingarray['customer_id'];
$nickname = $ratingarray['nickname'];
$detail = $ratingarray['detail'];
$review = Mage::getModel('review/review');
$review->setEntityPkValue($product_id);
$review->setStatusId(1);
$review->setTitle($title);
$review->setDetail($detail );
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE));
$review->setStoreId($storeid);
$review->setStatusId(1); //approved
$review->setCustomerId($customerid);
$review->setNickname($nickname);
$review->setReviewId($review->getId());
$review->setStores(array($storeid));
$review->save();
$review->aggregate();
//return "success";
$rating_options = $ratingarray['options'];
/*array(
array(1,2,3,4),
array(6,7,8),
array(11,12)
);*/
$row = count($rating_options);
$rating_id = 1;
foreach($rating_options as $key1=>$val1)
{
foreach($val1 as $key2=>$val2)
{
$_rating = Mage::getModel('rating/rating')
->setRatingId($key1)
->setReviewId($review->getId())
->addOptionVote($val2,$product_id );
}
}
return "Success";
}