我正在尝试从旧的magento站点导出和导入产品评论和评级到新的magento站点。如果不使用扩展,我不知道如何做到这一点。
这就是为什么我开始用程序创建评论和评级。我可以通过下面的代码片段创建复查。
<?php
ini_set('memory_limit', '128M');
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(1); //desired store id
$review = Mage::getModel('review/review');
$review->setEntityPkValue(1);//product id
$review->setStatusId(1);
$review->setTitle("mytitle");
$review->setDetail("mydetail");
$review->setEntityId(1);
$review->setStoreId(Mage::app()->getStore()->getId()); //storeview
$review->setStatusId(1); //approved
$review->setCustomerId(1);
$review->setNickname("Menickname");
$review->setReviewId($review->getId());
$review->setStores(array(Mage::app()->getStore()->getId()));
$review->save();
$review->aggregate();
?>
但是我不知道如何以编程方式创建评级。我完全不知道。有人能帮忙吗?
//Add ratings for each of the 3 rating options (Price, Quality, Value)
foreach($rating_options as $rating_id => $option_id):
echo "Rating ID: {$rating_id} - ";
echo "Review ID: " . $_review->getId() . " - ";
echo "Product ID: " . $_product->getId() . " - ";
echo "Option ID: " . $option_id . " - ";
try {
$_rating = Mage::getModel('rating/rating')
->setRatingId($rating_id)
->setReviewId($_review->getId())
->setCustomerId($_customer->getId())
->addOptionVote($option_id,$_product->getId());
} catch (Exception $e) {
die(var_dump($e));
}
endforeach;
$_review->save();
$_review->aggregate();
更多教程请参见下面的链接http://forum.azmagento.com/how to/add -产品-评价-以编程方式-或-迁移-评论和评级-线上购物- 61913. - html