OpenCart is fairly well optimised for search engine friendliness, and has support for SEO-friendly URLs out of the box. User reviews are not only a great way to provide feedback to customers about a product, but also a good way to keep product content fresh and attractive to search engines. However, OpenCart product reviews are displayed in the Reviews tab using AJAX. Search engine crawlers will not process the JavaScript used to pull the review content, and thus cannot read the reviews. I wrote this vqMod script which writes the review content into the HTML so it can be crawled.
<modification> <id>Make User Reviews Indexable</id> <version>1.0.0</version> <vqmver>2.1</vqmver> <author>countzer0</author> <file name="catalog/controller/product/product.php"> <operation> <search position="before"><![CDATA[$this->data['tags'] = array();]]></search> <add><![CDATA[ $this->data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], 0, 20); foreach ($results as $result) { $this->data['reviews'][] = array( 'author' => $result['author'], 'text' => strip_tags($result['text']), 'rating' => (int)$result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int)$review_total), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } ]]></add> </operation> </file> <file name="catalog/view/theme/default/template/product/product.tpl"> <operation> <search position="replace"><![CDATA[<div id="review"></div>]]></search> <add><![CDATA[ <div id="review"> <?php if ($reviews) { ?> <?php foreach ($reviews as $review) { ?> <div class="content"><b><?php echo $review['author']; ?></b> | <img src="catalog/view/theme/default/image/stars-<?php echo $review['rating'] . '.png'; ?>" alt="<?php echo $review['reviews']; ?>" /><br /> <?php echo $review['date_added']; ?><br /> <br /> <?php echo $review['text']; ?></div> <?php } ?> <?php } else { ?> <div class="content"><?php echo $text_no_reviews; ?></div> <?php } ?> </div> ]]></add> </operation> </file> </modification>
Note: the script pulls out all the reviews for the product, it doesn’t paginate them, so watch out if you have thousands of reviews! Also, the AJAX is left untouched. This script works with OpenCart 1.5.3.
Great, Thanks for sharing, It looks like we need to make some changes in our reviews module for making it easy for search engines to index all reviews.
http://www.fmeaddons.com/opencart/testimonials-plus-extension.html
OPENCART veriosn 1.5.6.x
REFERENCE https://www.mootpoint.org/blog/opencart-reviews-indexed-google-use-vqmod/
ERROR 2014-11-26 5:23:57 – PHP Notice: Undefined variable: text_no_reviews in /home/earthond/public_html/vqmod/vqcache/vq2-catalog_view_theme_vasco_template_product_product.tpl on line 282
SITE http://www.earthondrive.com
HI my name is jorg and I am trying to implement your reviews vqmod script on 1.5.6.x and I think it is working…
BUT I also am getting that error above in the opencart log in admin.
DATABASE has INSERT INTO `review` (`review_id`, `product_id`, `customer_id`, `author`, `text`, `rating`, `status`, `date_added`, `date_modified`)
GOOGLE not sure if it is working for the reviews. I’d sure like to get these reviews into GOOGLE!
LUVly script!
Tx
Hi Jorg
It seems that something has changed between 1.5.3 and 1.5.6 and the $text_no_reviews variable is no longer defined. You can fix this by replacing line 41 of the vqmod:
with
To check whether Google can see the reviews, view the source of a product page containing reviews and check to see if the review appears in the HTML. After waiting for Google to index the page (it might take days, or weeks), you can doublecheck that Google has indexed the review content by searching for:
Obviously, change the URL above to the URL of your product page. Click the text-only link in the top-right. If you can see the review text, it has been successfully indexed.
Alright Robin!
Googleing “We deploy these ECW image technologies and love the licensing model” works and the crawlers/spiders have discovered the HTML in the page views.
PROBLEM It seems that the customer reviews are not contained within my site, but instead are free floating.
WORKING Thanks for the vqmod script which I named reviews.xml and placed inside the vqmod/xml folder. But Am I still missing something?
I think you have a few problems here:
1. You have 2 domains with the same content: http://www.earthondrive.com and http://www.wavgen.com. This is very bad for Google’s duplicate content filters. You should ideally set up a 301 Permanently Moved redirect from one to the other, or block one of them from being indexed using robots.txt.
2. The vqmod is installed on http://www.earthondrive.com but not on http://www.wavgen.com.
3. Google has indexed the reviews on http://www.wavgen.com by following a link in the reviews AJAX (Javascript) code. This link goes to an HTML snippet containing the reviews only, which the AJAX pulls into the page normally to display the reviews dynamically. Google is displaying a link to the snippet in its results, not to the product page. So when people click on the link, they go to the snippet, without any navigation etc. Not good. This behaviour is nothing to do with my script, but because of the way OpenCart display reviews dynamically using Javascript.
The vqmod seems to be working on http://www.earthondrive.com. If you paste view-source:http://www.earthondrive.com/index.php?route=product/product&product_id=6903 into your browser, you will see the reviews in the HTML.
However, if you look at the copy of this page in Google’s cache (http://webcache.googleusercontent.com/search?q=cache:www.earthondrive.com/index.php%3Froute%3Dproduct/product%26product_id%3D6903&es_sm=91&strip=1), you will see that it doesn’t contain the reviews yet. This is because Google last updated its copy of the page on 20/10/14. You will need to wait a few days or weeks before Google updates the cache.
I managed to get it working properly.
Once again, thank you for kind help and the great extension
It sounds like the (int) type conversion isn’t working for the rating. A quick fix for now would be to comment out the alt tag section of product.tpl (in line 226 on your theme). I’ll try to look into a proper fix when I have 1.5.6.x installed.
Here is the error from the source code of a product page:
<img src="catalog/view/theme/oxy/image/stars/stars1-5.png" alt="Notice: Array to string conversion in D:\xampp\htdocs\opencart\catalog\view\theme\oxy\template\product\product.tpl on line 225Array" />
Notice: Array to string conversion in D:\xampp\htdocs\opencart\catalog\view\theme\oxy\template\product\product.tpl on line 226Array |
Write a review
On the store front it appears between the product stars and “write a review”:
NOTICE: ARRAY TO STRING CONVERSION IN D:\XAMPP\HTDOCS\OPENCART\CATALOG\VIEW\THEME\OXY\TEMPLATE\PRODUCT\PRODUCT.TPL ON LINE 226ARRAY
Tested on Oxy Theme and on default clean install of opencart
It sounds like a variable is incorrectly typed. Do the errors indicate which variable? Or can you see any review field with the value ARRAY?
Robin, thank you for this so much needed extension. I’ve tested in on the new opencart 1.5.6.4 and it shows NOTICE: ARRAY TO STRING CONVERSION errors. Could you advise how to fix it? Many thanks in advance