Categories
Magento

Magento : How to get Product Reviews posted during a time period

Well sometime you may want to show the review posted during specific date in magento. I goggled for this a lot and did not find any solution for this so i am sharing a very simple way to get the products reviews posted by guests/customers in Magento.

Customer reviews for your products and services always play a vital role in the success of your business. As magento have inbuilt functionality of reviews for products and when a customer write a review for product then the approved reviews will show on the product pages. If you are using service of Google Merchant Review Feeds then you need to submit the reviews posted between a specific dates. The following code snippet will be useful for you to get the magento product reviews.

How Magento Reviews are useful for growth of your business

<?php		// Added by Vaseem to get the product reviews posted during a time period
$fromDate	=	'2014-04-01 00:00:00';
$toDate		=	'2014-04-01 23:59:59';
$_reviews 	= 	Mage::getModel('review/review')
                ->getCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->addFieldToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
                ->setDateOrder()
                ->load();
foreach($_reviews as $review){
    $product 			= 	Mage::getModel('catalog/product')->load($review->getData('entity_pk_value'));
    $review_id			=	$review->getData('review_id');
    $created_at			=	$review->getData('created_at');
    $entity_id			=	$review->getData('entity_id');
    $entity_pk_value	=	$review->getData('entity_pk_value');
    $status_id			=	$review->getData('status_id');
    $detail_id			=	$review->getData('detail_id');
    $title				=	$review->getData('title');
    $detail				=	$review->getData('detail');
    $nickname			=	$review->getData('nickname');
    $customer_id		=	$review->getData('customer_id');
}
?>

I hope the above code will be useful for you šŸ™‚

Stay in touch

For a daily email update, click HERE or enter your email and stay on top of things by receiving weekly news in your inbox.

By Vaseem Ansari

Iā€™m Vaseem, a Software Engineer by Profession, a Traveler, a Foodie by Heart and the founder of VaseemAnsari.com. I started traveling from college days and it has become a part of me now. So when ever I happen to get a chance I pack my bag and am on the roads. You can follow me on these social networks Facebook, Twitter, Google+ and Linkedin.

One reply on “Magento : How to get Product Reviews posted during a time period”

Leave a Reply

Your email address will not be published. Required fields are marked *