Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8472707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:09:01+00:00 2026-06-10T17:09:01+00:00

I found the script below and its been said that it works, but Im

  • 0

I found the script below and its been said that it works, but I”m just not sure where or how they got the file/script to work and was hoping someone could help me shed some light.

There are multiple ways to import things into Magento – through a custom xml data file or just through a php script and thats what this says it is but i’m curious as to where its pulling the data from that its supposedly importing?

 <?php
ini_set('memory_limit', '128M');

require_once 'path-to-Mage.php';
Mage::app();

Mage::app()->setCurrentStore(4); //desired store id
$review = Mage::getModel('review/review');
$review->setEntityPkValue(147);//product id
$review->setStatusId(1);
$review->setTitle("title"); 
$review->setDetail("detail");
$review->setEntityId(1);                                      
$review->setStoreId(Mage::app()->getStore()->getId());                     
$review->setStatusId(1); //approved
$review->setCustomerId(273);//null is for administrator
$review->setNickname("Me");
$review->setReviewId($review->getId());
$review->setStores(array(Mage::app()->getStore()->getId()));                    
$review->save();
$review->aggregate();
?>

So if this is my php script where am I putting it? And can someone help me formulate the xml script I would use for importing?

Thanks in advance for any and all help

Meghan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:09:03+00:00Added an answer on June 10, 2026 at 5:09 pm

    What format are your reviews in currently that you wish to import?

    It seems you’d need to expand on this script, for example :open a file containing your reviews, cycle through them and use the above code inside this loop, replacing “title” and “detail” etc with the actual review information.

    Edited based on your comments below *****

    I’m assuming you have PHP and Magento coding experience – if not, perhaps you should look to get assistance from a developer.

    <?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(); 
    }
    
    ?>
    

    You’ll obviously need to replace $fileLocation with the directory location and file name of your CSV file. Each row of your CSV will be read into an array $line. The columns will map to the element numbers in the array. e.g. $line[0] is the first column of the row. You’ll need to alter the element references so that the data matches up to your CSV columns.

    This is enough for you to get going.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this script that gives you the username in Windows, but I get
I found a script on here that will export each worksheet in a file
I have just found a script we are using which has a sub that
I've found a script that seems perfect for my needs, but it uses IDs,
I was looking at the pagination script (posted below) and found it to be
How can I write text entities to a dxf file? I found a script
I am trying to write a script for matrix multiplication. Its just a basic
I have this script below which i found on SO to generate pagination and
How can I fix the script below so that it will work EVERY TIME!
I wrote the below batch script which asks for a JAVA_HOME path if its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.