Skip to content

Instantly share code, notes, and snippets.

Created August 20, 2010 20:52
Show Gist options
  • Save anonymous/541156 to your computer and use it in GitHub Desktop.
Save anonymous/541156 to your computer and use it in GitHub Desktop.
# 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
Product.find(:all, :conditions => {:enabled => true}).each do |product|
item = PowerReviews::FeedItem.new(
:name => product.name,
:category => feed_helper.get_product_categories(product),
:product_url => feed_helper.get_product_url(product),
:price => product.price_usd,
:image_url => feed_helper.get_product_image(product),
:description => coder.encode(product.translation('EN').description, :named),
:brand => 'Tubbs Snowshoes',
:page_id => product.name_data
)
feed << item
end
end
class PowerReviewsFeedHelper
include ActionController::UrlWriter
def get_product_url(product)
host = 'www.tubbssnowshoes.com'
case product.category
when 'products'
show_products_url(:host => host, :name_data => product.name_data)
when 'mens'
show_mens_url(:host => host, :name_data => product.name_data)
when 'womens'
show_womens_url(:host => host, :name_data => product.name_data)
when 'kids'
show_kids_url(:host => host, :name_data => product.name_data)
when 'accessories'
show_accessories_url(:host => host, :name_data => product.name_data)
else
path = host
end
end
def get_product_image(product)
prefix = $SCENE7_URL
case product.category
when 'skis'
prefix + 'is/image/TheGoods/tubbs_1011_' + product.name + '_side?$width_180px$'
end
end
def get_product_categories(product)
case product.category
when 'skis'
[product.category, product.series]
else
[product.category,{
'lock-jaw-carbon-alu-probe' => 'backcountry',
'lock-jaw-alu' => 'backcountry',
'6-speed' => 'men\'s',
'5-speed' => 'men\'s',
'4-speed' => 'men\'s',
'3-speed' => 'men\'s',
'automatic' => 'mens',
'3-speed-jr' => 'youth',
'6-karat' => 'women\'s',
'5-karat' => 'women\'s',
'4-karat' => 'women\'s',
'3-karat' => 'women\'s',
'1-4-karat' => 'youth',
'v12' => 'freestyle',
'v8' => 'freestyle',
'v6' => 'freestyle',
'v4' => 'freestyle',
'2-stroke' => 'youth',
'crossfire-pro' => 'men\'s',
'moxie-pro' => 'women\'s',
'edge' => 'unisex',
'clutch' => 'unisex',
'indy-helmet' => 'unisex',
'rant' => 'unisex',
'edge-jr' => 'youth',
'shadow' => 'youth'
}[product.name_data]]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment