Skip to content

Instantly share code, notes, and snippets.

@carolineschnapp
Created June 25, 2010 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carolineschnapp/453196 to your computer and use it in GitHub Desktop.
Save carolineschnapp/453196 to your computer and use it in GitHub Desktop.
class HomeController < ApplicationController
around_filter :shopify_session, :except => 'welcome'
def welcome
current_host = "#{request.host}#{':' + request.port.to_s if request.port != 80}"
@callback_url = "http://#{current_host}/login/finalize"
end
def index
@smart_collections = []
@custom_collections = []
@sorted = Hash.new([])
# get all smart collections
smart_collections = ShopifyAPI::SmartCollection.find(:all)
# parse the smart collections
smart_collections.each do |collection|
is_master_collection = true
SORT_ORDERS.each do |sort_order|
if collection.handle.include? sort_order
is_master_collection = false
master_collection_handle = collection.handle.gsub(sort_order,'');
puts master_collection_handle
@sorted[master_collection_handle] << sort_order
puts @sorted[master_collection_handle].inspect
end
end
if is_master_collection
@smart_collections << collection
end
end
# get all custom collections
custom_collections = ShopifyAPI::CustomCollection.find(:all)
# parse the smart collections
custom_collections.each do |collection|
is_master_collection = true
SORT_ORDERS.each do |sort_order|
if collection.handle.include? sort_order
is_master_collection = false
master_collection_handle = collection.handle.gsub(sort_order,'');
puts master_collection_handle
@sorted[master_collection_handle] << sort_order
puts @sorted[master_collection_handle].inspect
end
end
if is_master_collection
@custom_collections << collection
end
end
@sorted.each do |key,value|
puts key
puts value.to_s
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment