Create A Product Review In Magento
I am trying to import product reviews from an older site to our new Magento site.
I am having troubles trying to create the actual product review in a script. Has anyone tried doing this before and know how to accomplish this?
It looks like reviews use the entity models and I can't seem to get the review object开发者_如何学JAVA to do what I want it to do. Here is what I have tried doing so far and its throwing back some an error about foreign keys not being respected. Not sure how to make this work. Any help would be appreciated.
$review = Mage::getModel('review/review');
$review->setEntityPkValue(141292);
$review->setStatusId(1);
$review->setTitle("This is an inserted title");
$review->setDetail("This is an inserted detail");
$review->setNickname("First Last");
$review->save();
My guess would be that it's asking for a product and store to link the review with. Reading the install sql (under app/code/core/Mage/Review/sql/, it looks like there are constraints between review and each of:
- core_store
- catalog_product_entity
- review_status
- review_entity
Hope this helps, JD
精彩评论