-
-
Save beaucollins/541159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Unique for each merchant. Your merchant_group_id is located in the PowerReviews Dashboard > Merchant | |
# Group Properties section. | |
PowerReviews::Config.merchant_group_id = 11979 | |
# ID representing your website (default value is "1"). If you have multiple websites and would like to | |
# integrate PowerReviews onto each site, we can set your account as a Master Merchant. This enables | |
# review sharing and consolidated management among your different websites. When using the “Master | |
# Merchant” configuration, you assign a different Site ID to each site that will have reviews. This ID | |
# can be your own internal ID for the site or an ID assigned by PowerReviews. If you are implementing | |
# a single merchant, please leave the default Site ID set to "1". The Site ID is configurable in the | |
# Dashboard in the Merchant Properties section. | |
PowerReviews::Config.site_id = 1 | |
# Supply the Power Reviews feed processor with items to produce. Feed is an | |
# instance of PowerReviews::Feed. | |
# | |
# | |
PowerReviews::Feed.processor = lambda do |feed| | |
# UrlWriter so we can generate routes | |
require 'htmlentities' | |
feed_helper = PowerReviewsFeedHelper.new | |
coder = HTMLEntities.new | |
K2Client.config.line.products.each do |product| | |
product.reload | |
item = PowerReviews::FeedItem.new( | |
:name => product.name, | |
:category => feed_helper.get_product_categories(product), | |
:product_url => feed_helper.get_product_url(product), | |
:price => product.prices.first, | |
:image_url => feed_helper.get_product_image(product), | |
:description => coder.encode(product.translation.description, :named), | |
:brand => 'Tubbs Snowshoes', | |
:page_id => product.to_param | |
) | |
feed << item | |
end | |
end | |
class PowerReviewsFeedHelper | |
include ActionController::UrlWriter | |
def get_product_url(product) | |
host = 'www.tubbssnowshoes.com' | |
show_product_url(product, :host => host) | |
end | |
def get_product_image(product) | |
$SCENE7_URL + 'is/image/TheGoods/tubbs_1011_' + product.to_param + '_side?$width_180px$' | |
end | |
def get_product_categories(product) | |
product.categories.collect { |cat| cat.name } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment