I am trying to import some reviews programatically. I am using the following code:
$review = Mage::getModel('review/review');
$review->setEntityPkValue($product->getId());
$review->setStatusId(1);
$review->setTitle("title");
$review->setDetail("detail");
$review->setEntityId(1);
$review->setStoreId(Mage::app()->getStore()->getId());
$review->setStatusId(1);
$review->setCustomerId(NULL);
$review->setNickname("nickname");
$review->setReviewId($review->getId());
$review->setStores(array(Mage::app()->getStore()->getId()));
$review->setCreatedAt(Mage::getModel('core/date')->gmtTimestamp($date));
$review->save();
$review->aggregate();
$date is a timestamp of the date of the review.
The problem is that my reviews are being imported at the current date. How can I set the created_at parameter?
Best Answer
The problem is that the _beforeSave on the
Mage_Review_Model_Resource_Review
sets the created_at value when there is no id for the review, so for new reviews.You could do one of the following: