导入配置文件产品评论导入/导出

时间:2016-04-08 06:34:14

标签: magento

我使用Magento扩展程序https://www.magentocommerce.com/magento-connect/product-review-import-export.html导入产品评论。

我已从一个Magento网站导出评论,并且我试图在另一个网站上导入。

在导入产品时,它显示消息"已处理0%0/1记录"并保持显示,没有进口产品的过程。

Importing Preview

我在" app / code / local / MK / Reviewexport / Model / Convert / Adapter / Reviewimport.php"中更改了我的表格前缀。但仍然没有发生任何事情。

等了太久但它一直在向我显示"已处理0%0/1记录"我的评论太多,因此无法正常工作我已从CSV中删除了所有评论,只保留了一条评论。

此扩展程序由以下人员创建:https://magento.stackexchange.com/users/599/mufaddal

1 个答案:

答案 0 :(得分:1)

无论如何,我通过制作自定义脚本来导出由上述扩展程序导出的评论来解决问题。

这是一个代码

<?php
    ini_set('memory_limit', '128M');
    error_reporting(E_ALL);
    ini_set('display_errors', '1');

    require_once 'app/Mage.php';
    Mage::app();

    $fileLocation = "var/import/import_review.csv";
    $fp = fopen($fileLocation, 'r');
    $count = 1;

    while($data = fgetcsv($fp)){
        if($count > 1){
            //intiate requirement varibles
            $_createdAt     = $data[0];
            $_sku           = $data[1];
            $_catalog       = Mage::getModel('catalog/product');
            $_productId     = $_catalog->getIdBySku($_sku);
            $_statusId      = $data[2];
            $_title         = $data[3];
            $_detail        = $data[4];
            $_customerId    = NULL;
            $_nickname      = $data[5];

            //load magento review model and assign values
            $review = Mage::getModel('review/review');
            $review->setCreatedAt($_createdAt); //created date and time
            $review->setEntityPkValue($_productId);//product id
            $review->setStatusId($_statusId); // status id
            $review->setTitle($_title); // review title
            $review->setDetail($_detail); // review detail
            $review->setEntityId(1); // leave it 1
            $review->setStoreId(Mage::app()->getStore()->getId()); // store id
            $review->setCustomerId($_customerId); //null is for administrator
            $review->setNickname($_nickname); //customer nickname
            $review->setReviewId($review->getId());//set current review id
            $review->setStores(array(Mage::app()->getStore()->getId()));//store id's
            $review->save();
            $review->aggregate();

            //set review ratings
            if($data[7]){
                $arr_data = explode("@",$data[7]);
                if(!empty($arr_data)) {
                    foreach($arr_data as $each_data) {
                        $arr_rating = explode(":",$each_data);
                        if($arr_rating[1] != 0) {
                            Mage::getModel('rating/rating')
                            ->setRatingId($arr_rating[0])
                            ->setReviewId($review->getId())
                            ->setCustomerId($_customerId)
                            ->addOptionVote($arr_rating[1], $_productId);
                        }
                    }
                }
                $review->aggregate();
            }
        }
       // if($count == 5){
       //       die("total $count reviews are imported!");
       //  }
        $count++;
    }

    echo "total $count reviews are imported!";
?>
相关问题