I have a list of reviews with email id, how can I bulk import Product Reviews into Magento?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2019
11:45 PM
12 REPLIES 12
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
01:51 AM
05-25-2019
01:51 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
Hi @Aveeva,
You can import product reviews using custom script.
You can edit the following scripts per your csv file.
<CODE>
<?php
ini_set('memory_limit', '128M');
require_once 'path-to-Mage.php';
Mage::app();
$fp = fopen($fileLocation, 'r');
Mage::app()->setCurrentStore(4); //desired store id
while($line = fgetcsv($fp)) {
$review = Mage::getModel('review/review');
$review->setEntityPkValue($line[0]);//product id
$review->setStatusId($line[1]);
$review->setTitle($line[2]);
$review->setDetail($line[3]);
$review->setEntityId($line[4]);
$review->setStoreId(Mage::app()->getStore()->getId());
$review->setStatusId($line[5]); //approved
$review->setCustomerId($line[6]);//null is for administrator
$review->setNickname($line[7]);
$review->setReviewId($review->getId());
$review->setStores(array(Mage::app()->getStore()->getId()));
$review->save();
$review->aggregate();
}
?>
</CODE>
I hope it will help you.
You can import product reviews using custom script.
You can edit the following scripts per your csv file.
<CODE>
<?php
ini_set('memory_limit', '128M');
require_once 'path-to-Mage.php';
Mage::app();
$fp = fopen($fileLocation, 'r');
Mage::app()->setCurrentStore(4); //desired store id
while($line = fgetcsv($fp)) {
$review = Mage::getModel('review/review');
$review->setEntityPkValue($line[0]);//product id
$review->setStatusId($line[1]);
$review->setTitle($line[2]);
$review->setDetail($line[3]);
$review->setEntityId($line[4]);
$review->setStoreId(Mage::app()->getStore()->getId());
$review->setStatusId($line[5]); //approved
$review->setCustomerId($line[6]);//null is for administrator
$review->setNickname($line[7]);
$review->setReviewId($review->getId());
$review->setStores(array(Mage::app()->getStore()->getId()));
$review->save();
$review->aggregate();
}
?>
</CODE>
I hope it will help you.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
02:54 AM
05-25-2019
02:54 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
@Vimal Kumar I am okay with code, but i have confusion with excel format, can i get excel format??
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
03:50 AM
05-25-2019
03:50 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
@Aveeva,
Yes you can use excel format as well but in this case you need excel reader library file to read it and can change code accordingly..
But you can also save as excel file into csv file format.
Yes you can use excel format as well but in this case you need excel reader library file to read it and can change code accordingly..
But you can also save as excel file into csv file format.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
04:15 AM
05-25-2019
04:15 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
Reviews working now, how can i enable ratings also?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
05:07 AM
05-25-2019
05:07 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
Good to know that reviews are working fine.
You can enable ratings from admin panel:
Admin -> Catalogs ->Reviews and Ratings -> Manage Ratings ->Add/Edit Ratings.
I hope it will help you!
You can enable ratings from admin panel:
Admin -> Catalogs ->Reviews and Ratings -> Manage Ratings ->Add/Edit Ratings.
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
05:27 AM
05-25-2019
05:27 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
I need ratings also import by programmatically.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
05:35 AM
05-25-2019
05:35 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
You need to loop through all the voting options and create a rating for each option selected and like it back to your review.
<code>
foreach ($rating as $ratingId => $optionId) {
Mage::getModel('rating/rating')
->setRatingId($ratingId)
->setReviewId($review->getId())
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
->addOptionVote($optionId, $product->getId());
}
</code>
To get all the ratings you can use the rating's resource collection:
<code>
$ratingCollection = Mage::getModel('rating/rating')
->getResourceCollection()
->addEntityFilter('product')
->setPositionOrder()
->addRatingPerStoreName(Mage::app()->getStore()->getId())
->setStoreFilter(Mage::app()->getStore()->getId())
->load()
->addOptionToItems();
</code>
Then for each rating object you can call getOptions() to get each possible option for each rating.
For more info you can refer following link:
https://magento.stackexchange.com/questions/25018/how-to-create-product-rating-programmatically
<code>
foreach ($rating as $ratingId => $optionId) {
Mage::getModel('rating/rating')
->setRatingId($ratingId)
->setReviewId($review->getId())
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
->addOptionVote($optionId, $product->getId());
}
</code>
To get all the ratings you can use the rating's resource collection:
<code>
$ratingCollection = Mage::getModel('rating/rating')
->getResourceCollection()
->addEntityFilter('product')
->setPositionOrder()
->addRatingPerStoreName(Mage::app()->getStore()->getId())
->setStoreFilter(Mage::app()->getStore()->getId())
->load()
->addOptionToItems();
</code>
Then for each rating object you can call getOptions() to get each possible option for each rating.
For more info you can refer following link:
https://magento.stackexchange.com/questions/25018/how-to-create-product-rating-programmatically
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2019
08:21 AM
05-25-2019
08:21 AM
Re: How to Bulk import Product Reviews in Magento 1.9?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2019
09:57 PM
05-26-2019
09:57 PM
Re: How to Bulk import Product Reviews in Magento 1.9?
The below code okay with review how can i add rating values in CSV?
<?php require_once 'app/Mage.php'; // Load Mage Mage::app(); // Init Mage ini_set('memory_limit', '128M'); $fp = fopen('reviews.csv', 'r'); Mage::app()->setCurrentStore(1); //desired store id while($line = fgetcsv($fp)) { $review = Mage::getModel('review/review'); $review->setEntityPkValue($line[0]);//product id //a $review->setStatusId($line[1]); //b $review->setTitle($line[2]); //c $review->setDetail($line[3]); //d $review->setEntityId($line[4]); //e $review->setStoreId(Mage::app()->getStore()->getId()); $review->setStatusId($line[5]); //approved //f $review->setCustomerId($line[6]);//null is for administrator //g $review->setNickname($line[7]); //h $review->setReviewId($review->getId()); $review->setStores(array(Mage::app()->getStore()->getId())); $review->save(); $review->aggregate(); } ?>