I'm trying to create product review programmatically, using the below code
<?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();
?>
When I set customer Id $review->setCustomerId(1)
like this, it creates review for the product by customer with id=1 and when I use this $review->setCustomerId()
, it creates review for the product by Guest. But I could not make review by administrator, I tried the below
$review->setCustomerId(null)
This also set review by Guest. How to create review for product by administrator?
Best Answer
@SIBHI S, I founded of your issue. Replace the following code as
I hope this is resolved your issue.