Skip to content

Instantly share code, notes, and snippets.

@trabulium
Last active July 14, 2017 05:47
Show Gist options
  • Save trabulium/9097bafaee3ac6df731dfae96c1abda2 to your computer and use it in GitHub Desktop.
Save trabulium/9097bafaee3ac6df731dfae96c1abda2 to your computer and use it in GitHub Desktop.
Export Reviews from Magento to Yotpo format
select DISTINCT cpe.entity_id product_id, cpev3.value product_title, CONCAT('http://www.domain.com.au/', cur.request_path) product_url, rd.detail review_content, rov.value review_score, rd.title review_title, rd.nickname display_name, ce.email email, CONCAT('http://www.domain.com.au/media/catalog/product', cpev2.value) product_image_url, DATE_FORMAT(r.created_at,'%Y-%m-%d') date, '' product_description, '' cf_title_X, '' review_image_urls, '' comment_content, '' comment_public, '' comment_created_at
from review as r
LEFT JOIN review_detail rd on r.review_id = rd.review_id
LEFT JOIN catalog_product_entity cpe on r.entity_pk_value = cpe.entity_id
LEFT JOIN catalog_product_entity_int cpei on cpei.`entity_id` = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev on cpev.entity_id = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev2 on cpev2.entity_id = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev3 on cpev3.entity_id = cpe.entity_id
LEFT JOIN rating_option_vote rov on rov.review_id = r.review_id
LEFT JOIN customer_entity ce on ce.entity_id = rd.customer_id
LEFT JOIN core_url_rewrite cur on cur.product_id = cpe.entity_id
where cur.category_id is NULL
AND cpei.attribute_id = 96 AND cpei.`value` <> 2 #96 = status
AND cur.request_path IS NOT NULL
AND cpev.attribute_id = 97 #97 = url_key
AND cpev2.attribute_id = 85 #85 = image
AND cpev3.attribute_id = 71 #71 = name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment