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);
}
ありがとう!