Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Last active January 4, 2023 17:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveosoule/68486999df00d3bb7cf390440770e009 to your computer and use it in GitHub Desktop.
Save steveosoule/68486999df00d3bb7cf390440770e009 to your computer and use it in GitHub Desktop.
Miva - Google Merchant Center Product Review Feed from tgreviews content
<mvt:comment>
<!--
## Resources:
- https://developers.google.com/product-review-feeds
- https://developers.google.com/product-review-feeds/sample/
- https://www.google.com/shopping/reviews/schema/product/2.2/product_reviews.xsd
## Installation:
1. Create a Marketing Feed
2. Use the "Template Based Feed" "Feed Module"
3. Enable File Creation
4. Set the file path to point to an existing location (ex "/feeds/product-reviews.xml")
5. Edit the template
6. Assign the `tgreviews` item to the marketing-feed page
6. Set the "Mode" to "Product"
7. Set the "Encoding" to "None"
8. Adjust the g.TGR_Count assignment below to an appropriate amount for your needs.
-->
</mvt:comment>
<mvt:assign name="g.TGR_Count" value="99" />
<mvt:item name="templatefeed" />
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "http://www.google.com/shopping/reviews/schema/product/2.2/product_reviews.xsd">
<version>2.2</version>
<publisher>
<name>&mvte:store:name;</name>
</publisher>
<reviews>
<mvt:capture variable="l.null">
<mvt:comment><!-- Rendering this item added a bunch of white-space to the output, so I put it in an mvt:capture to remove the white-space --></mvt:comment>
<mvt:item name="tgreviews" param="Load_Product_Reviews( l.settings:record:id, l.settings:record:tgreviews )" />
</mvt:capture>
<mvt:foreach iterator="review" array="record:tgreviews:reviews">
<mvt:if expr="NOT l.settings:review:approved">
<mvt:foreachcontinue />
</mvt:if>
<review>
<review_id>&mvte:review:id;</review_id>
<mvt:if expr="l.settings:review:name OR l.settings:review:cust_id">
<reviewer>
<mvt:if expr="l.settings:review:name">
<name>&mvte:review:name;</name>
<mvt:else>
<name is_anonymous="true">Anonymous</name>
</mvt:if>
<mvt:if expr="l.settings:review:cust_id">
<reviewer_id>&mvte:review:cust_id;</reviewer_id>
</mvt:if>
</reviewer>
</mvt:if>
<mvt:do file="g.Module_Library_Utilities" name="l.settings:review:formatted_created" value="Format_SOAP_DateTime( l.settings:review:created )" />
<review_timestamp>&mvte:review:formatted_created;</review_timestamp>
<title>&mvte:review:title;</title>
<content>&mvte:review:summary;</content>
<review_url type="group">&mvte:record:url;</review_url>
<mvt:comment><pros />
<cons /></mvt:comment>
<ratings>
<overall min="1" max="5">&mvte:review:rating;</overall>
</ratings>
<products>
<product>
<product_ids>
<skus>
<mvt:if expr="l.settings:record:sku">
<sku>&mvte:record:sku;</sku>
<mvt:else>
<sku>&mvte:record:code;</sku>
</mvt:if>
</skus>
</product_ids>
<product_name>&mvte:record:name;</product_name>
<product_url>&mvte:record:url;</product_url>
</product>
</products>
</review>
</mvt:foreach>
<mvt:if expr="g.Debug">
<mvt:assign name="g.mvt_debug" value="glosub( miva_array_serialize( l.settings:record ), ',', asciichar( 10 ) )" />
<!--
@@record
====================
&mvt:global:mvt_debug;
-->
</mvt:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment