spree_froomerce_fconnect 0.70.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +11 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +20 -0
  4. data/Gemfile.lock +222 -0
  5. data/LICENSE +26 -0
  6. data/README.md +76 -0
  7. data/Rakefile +31 -0
  8. data/Versionfile +2 -0
  9. data/app/assets/images/loading.gif +0 -0
  10. data/app/assets/javascripts/admin/froomerces.js +2 -0
  11. data/app/assets/javascripts/admin/spree_froomerce_fconnect.js +1 -0
  12. data/app/assets/javascripts/froomerce_products.js +2 -0
  13. data/app/assets/javascripts/store/spree_froomerce_fconnect.js +1 -0
  14. data/app/assets/stylesheets/admin/froomerces.css +4 -0
  15. data/app/assets/stylesheets/admin/spree_froomerce_fconnect.css +3 -0
  16. data/app/assets/stylesheets/application.css +107 -0
  17. data/app/assets/stylesheets/froomerce_products.css +4 -0
  18. data/app/assets/stylesheets/store/spree_froomerce_fconnect.css +3 -0
  19. data/app/controllers/admin/froomerces_controller.rb +200 -0
  20. data/app/controllers/froomerce_products_controller.rb +79 -0
  21. data/app/helpers/admin/froomerces_helper.rb +2 -0
  22. data/app/helpers/froomerce_products_helper.rb +2 -0
  23. data/app/models/froomerce_config.rb +8 -0
  24. data/app/models/froomerce_product_status.rb +11 -0
  25. data/app/models/froomerce_user.rb +3 -0
  26. data/app/models/product_decorator.rb +4 -0
  27. data/app/models/taxon_decorator.rb +20 -0
  28. data/app/overrides/froomerce_tab.rb +5 -0
  29. data/app/views/admin/froomerces/export_facebook.html.erb +122 -0
  30. data/app/views/admin/froomerces/export_facebook_widgets.html.erb +108 -0
  31. data/app/views/admin/froomerces/export_shop.html.erb +56 -0
  32. data/app/views/admin/froomerces/index.html.erb +39 -0
  33. data/app/views/admin/shared/_froomerce_sub_menu.html.erb +8 -0
  34. data/app/views/froomerce_products/call_backs.html.erb +25 -0
  35. data/app/views/froomerce_products/feed_url.xml.builder +86 -0
  36. data/app/views/froomerce_products/index.xml.builder +83 -0
  37. data/config/locales/en.yml +72 -0
  38. data/config/routes.rb +29 -0
  39. data/db/migrate/20120111085252_create_froomerce_users.rb +11 -0
  40. data/db/migrate/20120113072837_create_froomerce_configs.rb +12 -0
  41. data/db/migrate/20120203125952_create_froomerce_product_statuses.rb +10 -0
  42. data/lib/api_calls.rb +37 -0
  43. data/lib/call_backs.rb +141 -0
  44. data/lib/generators/spree_froomerce_fconnect/install/install_generator.rb +20 -0
  45. data/lib/spree_froomerce_fconnect/engine.rb +25 -0
  46. data/lib/spree_froomerce_fconnect.rb +2 -0
  47. data/script/rails +7 -0
  48. data/spec/controllers/admin/froomerces_controller_spec.rb +5 -0
  49. data/spec/controllers/froomerce_products_controller_spec.rb +5 -0
  50. data/spec/helpers/admin/froomerces_helper_spec.rb +15 -0
  51. data/spec/helpers/froomerce_products_helper_spec.rb +15 -0
  52. data/spec/models/froomerce_config_spec.rb +5 -0
  53. data/spec/models/froomerce_product_status_spec.rb +5 -0
  54. data/spec/models/froomerce_user_spec.rb +5 -0
  55. data/spec/spec_helper.rb +31 -0
  56. data/spree_froomerce_fconnect.gemspec +20 -0
  57. metadata +113 -0
@@ -0,0 +1,39 @@
1
+ <div>
2
+ <div>
3
+ <h1><%= t('.heading') %></h1>
4
+ </div>
5
+ <fieldset>
6
+ <div>
7
+ <h2><%= t('.user_info') %></h2>
8
+ <div style="float:right;margin-top:-28px;">
9
+ <%=t('having_problem') %><a href="mailto:support@froomerce.com"><%=t('here') %></a>
10
+ </div>
11
+ </div>
12
+ <center>
13
+ <div>
14
+ <ul>
15
+ <%= form_for :froomerce_user, :url => {:action => :create} do |f| %>
16
+ <p>
17
+ <%= f.label :email, t('.user') %>
18
+ <%= f.text_field :email, :style => "margin-left:25px", :size => 60 %>
19
+ <br/>
20
+ <%= f.label :password, t('.password') %>
21
+ <%= f.password_field :password, :size => 60 %>
22
+ <br/>
23
+ </p>
24
+ <div>
25
+ <button type="reset">
26
+ <span><%= t('reset') %></span>
27
+ </button>
28
+ <button type="submit">
29
+ <span><%= t('auth') %></span>
30
+ </button>
31
+ </div>
32
+ <% end %>
33
+ </ul>
34
+ <div>
35
+ </div>
36
+ </div>
37
+ </center>
38
+ </div>
39
+ </fieldset>
@@ -0,0 +1,8 @@
1
+ <% unless FroomerceUser.first.nil? %>
2
+ <% content_for :sub_menu do %>
3
+ <ul id="sub_nav">
4
+ <%= tab :export_shop, :css_class => ( params[:action] == "export_shop" ) ? "selected" : "" %>
5
+ <%= tab :export_facebook, :label => 'admin.froomerces.export_facebook.heading', :css_class => ( params[:action] == "export_facebook" || params[:action] == "export_facebook_widgets" ) ? "selected last" : "last" %>
6
+ </ul>
7
+ <% end %>
8
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <script src="/assets/store/all.js" type="text/javascript">
2
+ </script>
3
+ <%= form_tag populate_orders_path, :id => 'add_to_cart', :method => :post do %>
4
+ <% @products.each do |product_id,variant_id| %>
5
+ <input type="hidden" name="products[<%=product_id%>]" value="<%=variant_id%>"><%end %>
6
+ <% @quantity.each do |variant_id,quantity| %>
7
+ <input type="hidden" name="variants[<%=variant_id%>]" value="<%=quantity%>"><%end %>
8
+ <% end %>
9
+ <%= form_tag empty_cart_path, :id => 'flush_cart', :method => :put do %>
10
+ <%end %>
11
+ <div style='text-align:center;margin-top:200px'>
12
+ <%= image_tag 'loading.gif', :alt => '' %>
13
+ <p>
14
+ <h2>loading..........</h2>
15
+ </p>
16
+ </div>
17
+ <script type="text/javascript">
18
+ $.ajax({
19
+ type: "PUT",
20
+ url: '/cart/empty',
21
+ success: function(){
22
+ $('#add_to_cart').submit();
23
+ }
24
+ });
25
+ </script>
@@ -0,0 +1,86 @@
1
+ xml.instruct! :xml, :version=>"1.0"
2
+
3
+ xml.data do
4
+ xml.products do
5
+ @products.each do |product|
6
+ unless product.count_on_hand < 1
7
+ xml.product do
8
+ xml.product_id{xml.cdata!("#{product.id}")}
9
+ if product.has_variants?
10
+ xml.is_configurable{xml.cdata!("#{1}")}
11
+ else
12
+ xml.is_configurable{xml.cdata!("#{0}")}
13
+ end
14
+ xml.title{xml.cdata!(product.name)}
15
+ price = product.price
16
+ xml.price{xml.cdata!("#{price}")}
17
+ xml.shipping_info
18
+ xml.currency_symbol{xml.cdata!((number_to_currency price).gsub(/[^$]/, ""))}
19
+ xml.product_link{xml.cdata!(root_url + "products/" + product.permalink)}
20
+ i = 1
21
+ if @taxon
22
+ categories = ""
23
+ product.taxons.each do |tax|
24
+ if cate = tax.is_category("")
25
+ categories = cate+","+categories
26
+ end
27
+ end
28
+ xml.category_id{xml.cdata!(categories.chop)}
29
+ else
30
+ xml.category_id
31
+ end
32
+ product.images.each do |image|
33
+ if i
34
+ xml.image_small{xml.cdata!(root_url.chop+image.attachment.url(:small))}
35
+ xml.image_large{xml.cdata!(root_url.chop+image.attachment.url(:large))}
36
+ i = nil
37
+ else
38
+ xml.img{xml.cdata!(root_url.chop+image.attachment.url(:large))}
39
+ end
40
+ end
41
+ if product.description
42
+ xml.product_detail{xml.cdata!(product.description)}
43
+ else
44
+ xml.product_detail
45
+ end
46
+ if product.properties
47
+ xml.attributes do
48
+ i = 0
49
+ product.properties.each do |property|
50
+ xml.attribute do
51
+ xml.label{xml.cdata!(property.presentation)}
52
+ xml.value{xml.cdata!(product.product_properties[i].value)}
53
+ end
54
+ i += 1
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ if @taxon && @page_no == 1
63
+ xml.categories do
64
+ @taxon.each do |tax|
65
+ if tax.parent_id.blank?
66
+ if tax.has_children?
67
+ xml.category do
68
+ xml.parent_id{xml.cdata!("0")}
69
+ xml.category_id{xml.cdata!("#{tax.id}")}
70
+ xml.category_name{xml.cdata!(tax.name)}
71
+ end
72
+ end
73
+ else
74
+ xml.category do
75
+ xml.parent_id{xml.cdata!("#{tax.parent_id}")}
76
+ xml.category_id{xml.cdata!("#{tax.id}")}
77
+ xml.category_name{xml.cdata!(tax.name)}
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ if @page_no
84
+ xml.next_page{xml.cdata!(root_url+"froomerce_feed?page=#{@page_no+1}&per_page=#{FroomerceConfig::FEED_CONFIG[:feed_per_page]}")}
85
+ end
86
+ end
@@ -0,0 +1,83 @@
1
+ xml.instruct! :xml, :version=>"1.0"
2
+
3
+ xml.data do
4
+ xml.products do
5
+ @products.each do |product|
6
+ unless product.count_on_hand < 1
7
+ xml.product do
8
+ xml.product_id{xml.cdata!("#{product.id}")}
9
+ if product.has_variants?
10
+ xml.is_configurable{xml.cdata!("#{1}")}
11
+ else
12
+ xml.is_configurable{xml.cdata!("#{0}")}
13
+ end
14
+ xml.title{xml.cdata!(product.name)}
15
+ price = product.price
16
+ xml.price{xml.cdata!("#{price}")}
17
+ xml.shipping_info
18
+ xml.currency_symbol{xml.cdata!((number_to_currency price).gsub(/[^$]/, ""))}
19
+ xml.product_link{xml.cdata!(root_url+"products/"+product.permalink)}
20
+ i = 1
21
+ if @taxon
22
+ categories = ""
23
+ product.taxons.each do |tax|
24
+ if cate = tax.is_category("")
25
+ categories = cate+","+categories
26
+ end
27
+ end
28
+ xml.category_id{xml.cdata!(categories.chop)}
29
+ else
30
+ xml.category_id
31
+ end
32
+ product.images.each do |image|
33
+ if i
34
+ xml.image_small{xml.cdata!(root_url.chop+image.attachment.url(:small))}
35
+ xml.image_large{xml.cdata!(root_url.chop+image.attachment.url(:large))}
36
+ i = nil
37
+ else
38
+ xml.img{xml.cdata!(root_url.chop+image.attachment.url(:large))}
39
+ end
40
+ end
41
+ if product.description
42
+ xml.product_detail{xml.cdata!(product.description)}
43
+ else
44
+ xml.product_detail
45
+ end
46
+ if product.properties
47
+ xml.attributes do
48
+ i = 0
49
+ product.properties.each do |property|
50
+ xml.attribute do
51
+ xml.label{xml.cdata!(property.presentation)}
52
+ xml.value{xml.cdata!(product.product_properties[i].value)}
53
+ end
54
+ i += 1
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ if @taxon
63
+ xml.categories do
64
+ @taxon.each do |tax|
65
+ if tax.parent_id.blank?
66
+ if tax.has_children?
67
+ xml.category do
68
+ xml.parent_id{xml.cdata!("0")}
69
+ xml.category_id{xml.cdata!("#{tax.id}")}
70
+ xml.category_name{xml.cdata!(tax.name)}
71
+ end
72
+ end
73
+ else
74
+ xml.category do
75
+ xml.parent_id{xml.cdata!("#{tax.parent_id}")}
76
+ xml.category_id{xml.cdata!("#{tax.id}")}
77
+ xml.category_name{xml.cdata!(tax.name)}
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,72 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ froomerces: Froomerce
6
+ export_shop: Export Shop
7
+ export_facebook: Export Facebook
8
+
9
+ having_problem: Having Problems? Contact Us
10
+ here: here
11
+ reset: Reset
12
+ auth: Authenticate
13
+ shop_success: Your Shop has been Successfully Exported!
14
+ shop_select: Please select a shop first!
15
+ widget_saved: Your widget has been exported, click
16
+ widget_continue: to post to Facebook wall.
17
+ notify_truncate: All Plugin tables are truncated!
18
+
19
+ error:
20
+ e100: An internal error occurred, Please try again!
21
+ e101: An internal error occurred, Please try again!
22
+ e102: An internal error occurred, Please try again!
23
+ e103: An internal error occurred, Please try again!
24
+ e104: Credentials are Invalid, Please try again!
25
+ e105: User is not a Merchant
26
+ e106: Could not connect to server, Please try again!
27
+ e107: An internal error occurred, Please try again!
28
+ e108: Invalid user
29
+ e109: An internal error occurred, Please try again!
30
+ e110: An internal error occurred, Please try again!
31
+ e111: An internal error occurred, Please try again!
32
+ e112: We were not able to export your widget yet, Please try agian!
33
+ validation_error: Wrong format of credentials!
34
+ HTTPfaliure: Could not access the server, Plaese try again!
35
+ no_session: Please login first!
36
+ shop_error: Shop could not be created due to some error, Please try again!
37
+ invalid_selection: Please select shop and a region to export!
38
+ invalid_widget_selection: Please select atleast 1 product to post a widget.
39
+ no_privilege: You are not privileged to truncate Plugin Data.
40
+
41
+ admin:
42
+ froomerces:
43
+ index:
44
+ heading: Add Froomerce User
45
+ user_info: User Information
46
+ user: Froomerce User
47
+ password: Froomerce Password
48
+
49
+ export_shop:
50
+ heading: Export to Froomerce
51
+ select_shop: Select one of your shops to export to froomerce
52
+ export: Export to Froomerce
53
+ main_shop: Main Shop
54
+ choose_region: Choose the region that is related to your shop
55
+
56
+ export_facebook:
57
+ heading: Export to Facebook
58
+ description: Only those shops can be exported to facebook which are already exported to froomerce
59
+ export_facebook: Export Shop to Facebook
60
+ export_widget: Export Widget to Facebook
61
+ submit: Export
62
+ main_shop: Main Shop
63
+ exported: Exported!
64
+ not_exported: Not exported to Froomerce yet!
65
+
66
+ export_facebook_widgets:
67
+ heading: Export as widget to Facebook
68
+ id: ID
69
+ count_on_hand: Quantity
70
+ submit: Submit
71
+ filter: Filter
72
+ export: Export
data/config/routes.rb ADDED
@@ -0,0 +1,29 @@
1
+ Rails.application.routes.draw do
2
+
3
+ namespace :admin do
4
+ resources :froomerces do
5
+ get :export_facebook
6
+ get :export_shop
7
+ post :create_shop
8
+ get :export_products
9
+ get :export_facebook_widgets
10
+ post :make_widget
11
+ end
12
+ match 'froomerce' => 'froomerces#index', :as => :froomerce
13
+ match 'froomerce/export_to_facebook' => 'froomerces#export_facebook', :as => :export_facebook
14
+ match 'froomerce/export_to_froomerce' => 'froomerces#export_shop', :as => :export_shop
15
+ match 'froomerce/creating_shop' => 'froomerces#create_shop'
16
+ match 'froomerce/exporting_products' => 'froomerces#export_products'
17
+ match 'froomerce/export_widgets_to_facebook' => 'froomerces#export_facebook_widgets'
18
+ match 'froomerce/make_widget' => 'froomerces#make_widget'
19
+ end
20
+
21
+ resources :froomerce_products do
22
+ get :feed_url
23
+ get :call_backs
24
+ get :post_widget
25
+ end
26
+ match 'froomerce_feed' => 'froomerce_products#feed_url', :as => :feed_url
27
+ match 'froomerce_call_backs' => 'froomerce_products#call_backs'
28
+ match 'truncate_froomerce_configuration' => 'froomerce_products#truncate_all_tables'
29
+ end
@@ -0,0 +1,11 @@
1
+ class CreateFroomerceUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :froomerce_users do |t|
4
+ t.string :email, :null => false
5
+ t.string :password, :null => false
6
+ t.integer :froomerce_user_id, :null => false
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateFroomerceConfigs < ActiveRecord::Migration
2
+ def change
3
+ create_table :froomerce_configs do |t|
4
+ t.integer :region_id, :null => false, :default => 0
5
+ t.integer :shop_id, :null => false, :default => 0
6
+ t.integer :froomerce_shop_id, :null => false, :default => 0
7
+ t.column :status, "ENUM('Inprogress','Exporting Products', 'Exported')", :default => 'Inprogress'
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateFroomerceProductStatuses < ActiveRecord::Migration
2
+ def change
3
+ create_table :froomerce_product_statuses, :id => false do |t|
4
+ t.integer :product_id, :null => false
5
+ t.column :status, :boolean, :default => true, :null => false
6
+ t.timestamps
7
+ end
8
+ execute "ALTER TABLE froomerce_product_statuses ADD PRIMARY KEY (product_id);"
9
+ end
10
+ end
data/lib/api_calls.rb ADDED
@@ -0,0 +1,37 @@
1
+ module Api_calls
2
+
3
+ def make_api_call(query, relative_url, is_varifi, email)
4
+ return -1 unless query
5
+ if is_dummy?(email)
6
+ url = URI.parse(FroomerceConfig::VERIFICATION[:temp_base]+relative_url)
7
+ else
8
+ url = URI.parse(FroomerceConfig::VERIFICATION[:base]+relative_url)
9
+ end
10
+
11
+ http = Net::HTTP.new(url.host, url.port)
12
+ request = Net::HTTP::Get.new(url.path + "?secret_token=#{FroomerceConfig::VERIFICATION[:token]}&#{query}")
13
+ if is_varifi == 1 then http.use_ssl = (url.scheme == 'https') end
14
+ if is_varifi == 2
15
+ response, status = Net::HTTP.post_form(url ,query)
16
+ else
17
+ response = http.start {|http| http.request(request) }
18
+ status = http.request(request).body
19
+ end
20
+ case response
21
+ when Net::HTTPSuccess then
22
+ result = JSON.parse(status)
23
+ return result
24
+ else
25
+ return -1
26
+ end
27
+ end
28
+
29
+ def is_dummy?(email)
30
+ if email.eql? 'dummy.export@servis.pk'
31
+ return true
32
+ else
33
+ return false
34
+ end
35
+ end
36
+
37
+ end
data/lib/call_backs.rb ADDED
@@ -0,0 +1,141 @@
1
+ class CallBacks
2
+
3
+ def get_attributes(params, root_url)
4
+ id = params[:product_id]
5
+ begin
6
+ product = Product.find(id)
7
+ rescue
8
+ return nil
9
+ end
10
+ options = product.product_option_types
11
+ hash = Hash.new
12
+ return nil unless options.count > 1
13
+ types = []
14
+ types = options.collect {|opt| opt.option_type }
15
+ variants = Variant.find_all_by_product_id(id)
16
+ prod_images = product.images.collect {|img| root_url.chop + img.attachment.url}
17
+ product_images = prod_images.join('^')
18
+ i = 0; j=0
19
+ variants.each do |variant|
20
+ unless variant.is_master
21
+ values = variant.option_values.order('option_type_id ASC')
22
+ images = variant.images.collect {|img| root_url.chop + img.attachment.url}
23
+ additional_images = images.join('^')
24
+ if additional_images.blank?
25
+ additionl_images_url = product_images
26
+ else
27
+ additionl_images_url = product_images + '^' + additional_images
28
+ end
29
+ if additional_images.blank?
30
+ hash[i] = {'product_id' => variant.id, 'price' => variant.price}
31
+ else
32
+ hash[i] = {'product_id' => variant.id, 'price' => variant.price, 'additional_imgs' => additionl_images_url, 'cart_img' => root_url.chop + variant.images.first.attachment.url}
33
+ end
34
+ types.each do |type|
35
+ hash[i][type.presentation] = values[j].presentation
36
+ j = j.succ
37
+ end
38
+ i = i.succ
39
+ j = 0
40
+ end
41
+ additional_images = ''
42
+ additionl_images_url = ''
43
+ end
44
+ return hash
45
+ end
46
+
47
+ def export_completed
48
+ config = FroomerceConfig.first
49
+ config.update_attribute(:status, 'Exported')
50
+ return {'status' => 'success'}
51
+ end
52
+
53
+ def exported_products(params)
54
+ FroomerceProductStatus.update_all(:status => false) if params[:first] && FroomerceProductStatus
55
+ if params[:product_ids]
56
+ products_ids = params[:product_ids].split(',')
57
+ products_ids.each do |id|
58
+ begin
59
+ status = FroomerceProductStatus.find(id)
60
+ status.update_attribute(:status, true)
61
+ rescue
62
+ status = FroomerceProductStatus.new(:status => true)
63
+ status.init_product_id(id.to_i)
64
+ status.save!
65
+ end
66
+ end
67
+ end
68
+ FroomerceProductStatus.delete_all(:status => false) if params[:last] && FroomerceProductStatus
69
+ return {'status' => 'success'}
70
+ end
71
+
72
+ def verify_cart(params)
73
+ if params[:product_ids]
74
+ product_ids = params[:product_ids].split(',')
75
+ if params[:associated_ids]
76
+ variant_ids = params[:associated_ids].split(',')
77
+ if params[:quantities]
78
+ quantities = params[:quantities].split(',')
79
+ hash = {'status' => 'error', 'error' => {}}
80
+ flag = false
81
+ i = 0; j = 0
82
+ product_ids.each do |product_id|
83
+ if variant_ids[i].eql? '0'
84
+ begin
85
+ product = Product.find(product_id)
86
+ rescue
87
+ return nil
88
+ end
89
+ if product.count_on_hand < quantities[i].to_i
90
+ hash['error'][j] = {'name' => product.name, 'out_of_stock' => product_id, 'available_qty' => product.count_on_hand }
91
+ flag = true unless flag
92
+ end
93
+ else
94
+ begin
95
+ variant = Variant.find(variant_ids[i])
96
+ rescue
97
+ return nil
98
+ end
99
+ if variant.count_on_hand < quantities[i].to_i
100
+ hash['error'][j] = {'name' => variant.product.name, 'out_of_stock' => variant.id, 'available_qty' => variant.count_on_hand }
101
+ flag = true unless flag
102
+ end
103
+ end
104
+ i = i.succ; j = j.succ
105
+ end
106
+ if flag
107
+ return hash
108
+ else
109
+ return {'status' => 'success'}
110
+ end
111
+ else
112
+ return nil
113
+ end
114
+ else
115
+ return nil
116
+ end
117
+ else
118
+ return nil
119
+ end
120
+ end
121
+
122
+ def add_to_cart(params)
123
+ if params[:product_ids]
124
+ product_ids = params[:product_ids].split(',')
125
+ if params[:associated_ids]
126
+ variant_ids = params[:associated_ids].split(',')
127
+ if params[:quantities]
128
+ quantities = params[:quantities].split(',')
129
+ i = 0
130
+ product_ids.each do |product|
131
+ variant_ids[i] = Variant.find_by_product_id(product).id.to_s if variant_ids[i].eql? '0'
132
+ i = i.succ
133
+ end
134
+ products = Hash[*product_ids.zip(variant_ids).flatten]
135
+ quantity = Hash[*variant_ids.zip(quantities).flatten]
136
+ return products, quantity
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeFroomerceFconnect
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ def add_migrations
6
+ run 'bundle exec rake railties:install:migrations FROM=spree_froomerce_fconnect'
7
+ end
8
+
9
+ def run_migrations
10
+ res = ask "Would you like to run the migrations now? [Y/n]"
11
+ if res == "" || res.downcase == "y"
12
+ run 'bundle exec rake db:migrate'
13
+ else
14
+ puts "Skiping 'rake db:migrate', don't forget to run it!"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,25 @@
1
+ module SpreeFroomerceFconnect
2
+ class Engine < Rails::Engine
3
+ engine_name 'spree_froomerce_fconnect'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
14
+ Rails.application.config.cache_classes ? require(c) : load(c)
15
+ end
16
+
17
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
18
+ Rails.application.config.cache_classes ? require(c) : load(c)
19
+ end
20
+
21
+ end
22
+
23
+ config.to_prepare &method(:activate).to_proc
24
+ end
25
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_froomerce_fconnect/engine'
data/script/rails ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+
5
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
6
+ load File.expand_path('../../spec/dummy/script/rails', __FILE__)
7
+
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Admin::FroomercesController do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe FroomerceProductsController do
4
+
5
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ # Specs in this file have access to a helper object that includes
4
+ # the Admin::FroomercesHelper. For example:
5
+ #
6
+ # describe Admin::FroomercesHelper do
7
+ # describe "string concat" do
8
+ # it "concats two strings with spaces" do
9
+ # helper.concat_strings("this","that").should == "this that"
10
+ # end
11
+ # end
12
+ # end
13
+ describe Admin::FroomercesHelper do
14
+ pending "add some examples to (or delete) #{__FILE__}"
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ # Specs in this file have access to a helper object that includes
4
+ # the FroomerceProductsHelper. For example:
5
+ #
6
+ # describe FroomerceProductsHelper do
7
+ # describe "string concat" do
8
+ # it "concats two strings with spaces" do
9
+ # helper.concat_strings("this","that").should == "this that"
10
+ # end
11
+ # end
12
+ # end
13
+ describe FroomerceProductsHelper do
14
+ pending "add some examples to (or delete) #{__FILE__}"
15
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe FroomerceConfig do
4
+ pending "add some examples to (or delete) #{__FILE__}"
5
+ end