Created
June 25, 2010 17:57
-
-
Save carolineschnapp/453196 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
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