【问题标题】:Import Profile Product Review import/export导入配置文件产品评论导入/导出
【发布时间】:2016-07-29 07:57:35
【问题描述】:

我正在使用 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

【问题讨论】:

  • 最好使用magento connect联系devoloper。
  • 开发者不回复,也尝试做个人邮件。

标签: magento


【解决方案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!";
?>

【讨论】:

    猜你喜欢
    • 2015-12-23
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 2018-01-15
    相关资源
    最近更新 更多