I want to add product reviews programatically with some custom fields defined on my code below
$review = Mage::getModel('review/review')
->setEntityPkValue(intval($pressquote->product_id)) //product id
->setStatusId(intval($pressquote->status))
->setDetail($pressquote->text)
->setTitle('')
->setEntityId(1)
->setStatusId(intval($pressquote->status)) //approved
->setCustomerId(null) //null is for administrator
->setNickname($pressquote->source)
->setLink($pressquote->link) //custom field
->setLinktext($pressquote->linktext) //custom field
->setYear($pressquote->year) //custom field
->setStoreId(1)
->setStores(array('base'))
->save();
but it doesn't work for me.. I checked my code and it stops on save()
. What went wrong?
I tried already removing the custom fields but nothing happened
Best Answer
// Invoke the Magento environment
// Set up your own loop to to go through the reviews from the source cart.
// Logic to look up customer that has already been migrated into magento. // So you have $_customer holding a Mage_Customer_Model_Customer
// IMPORTANT: Set up customer session. // the rating/option model resource checks the customer session to get the customer ID.
// Add the review
// Map your rating_id to your option_id with an array or something
// Now save the ratings