1
    $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();

I am not be able to save data on custom field above commented for custom field.

8
  • have you added custom fileds in database table "review" or any other table?
    – Abdul
    Dec 4, 2015 at 11:11
  • if you are added in "review" table then but first clear cash and indexing in admin side after try again
    – Abdul
    Dec 4, 2015 at 11:13
  • I have cleared cash but did not get save even I update just after inserting but did not get desire result.
    – Manish
    Dec 4, 2015 at 11:27
  • Which file or location added above code?
    – Abdul
    Dec 4, 2015 at 11:28
  • I have created a module and on crontroller xxxAction(), I am performing this task
    – Manish
    Dec 4, 2015 at 11:30

1 Answer 1

0

Based on comments, you want to import customers reviews from csv, so you can use this: https://www.magentocommerce.com/magento-connect/product-review-import-export.html

This extension is not ready to multistore but works fine. You can edit Adapter (MK_Reviewexport_Model_Convert_Adapter_Reviewimport) and add your custom field.

class MK_Reviewexport_Model_Convert_Adapter_Reviewimport extends Mage_Catalog_Model_Convert_Adapter_Product
{
    public function saveRow(array $data)
    {
        $write = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
        $sku = $write->query ( 'select entity_id from `catalog_product_entity` where sku = "' . $data ['Sku'] . '" ' );
        $sku = $sku->fetch ();

        if ($sku) {
            $product_id = $sku ['entity_id'];
            if ($data ['customer_id'] == '') {
                $customerid = NULL;
            } else {
                $customerid = $data ['customer_id'];
            }
            $_review = Mage::getModel ( 'review/review' )
                ->setCreatedAt ( $data ['created_at'] )
                ->setEntityPkValue ( $product_id )->setEntityId ( 1 )
                ->setStatusId ( $data ['status_id'] )
                ->setTitle ( $data ['title'] )->setDetail ( $data ['detail'] )
                ->setStoreId ( 1 )
                ->setStores ( 1 )
                ->setCustomerId ( $customerid )
                // set your custom field here.
                ->setNickname ( $data ['nickname'] )->save ();

            if ($data ['option_id']) {
                $arr_data = explode ( "@", $data ['option_id'] );

                if (! empty ( $arr_data )) {

                    foreach ( $arr_data as $each_data ) {

                        $arr_rating = explode ( ":", $each_data );

                        if ($arr_rating [1] != 0) {

                            Mage::getModel ( 'rating/rating' )
                                ->setRatingId ( $arr_rating [0] )
                                ->setReviewId ( $_review->getId () )
                                ->setCustomerId ( $customerid )
                                ->addOptionVote ( $arr_rating [1], $product_id );
                        }
                    }
                }
                $_review->aggregate ();
            }
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.