solidus_marketplace 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +11 -0
  5. data/Gemfile +8 -0
  6. data/LICENSE +26 -0
  7. data/README.md +123 -0
  8. data/Rakefile +15 -0
  9. data/Versionfile +6 -0
  10. data/app/assets/javascripts/spree/backend/solidus_marketplace.js +5 -0
  11. data/app/assets/javascripts/spree/backend/solidus_marketplace_routes.js +1 -0
  12. data/app/assets/javascripts/spree/backend/suppliers_autocomplete.js +55 -0
  13. data/app/assets/javascripts/spree/frontend/solidus_marketplace.js +1 -0
  14. data/app/assets/stylesheets/spree/backend/solidus_marketplace.scss +22 -0
  15. data/app/assets/stylesheets/spree/frontend/solidus_marketplace.css +3 -0
  16. data/app/controllers/ckeditor/attachment_files_controller_decorator.rb +20 -0
  17. data/app/controllers/ckeditor/pictures_controller_decorator.rb +17 -0
  18. data/app/controllers/spree/admin/marketplace_settings_controller.rb +19 -0
  19. data/app/controllers/spree/admin/products_controller_decorator.rb +79 -0
  20. data/app/controllers/spree/admin/reports_controller_decorator.rb +68 -0
  21. data/app/controllers/spree/admin/shipments_controller.rb +47 -0
  22. data/app/controllers/spree/admin/stock_items_controller_decorator.rb +10 -0
  23. data/app/controllers/spree/admin/stock_locations_controller_decorator.rb +23 -0
  24. data/app/controllers/spree/admin/suppliers_controller.rb +54 -0
  25. data/app/controllers/spree/admin/users_controller_decorator.rb +34 -0
  26. data/app/controllers/spree/api/suppliers_controller.rb +16 -0
  27. data/app/controllers/spree/api/v1/stock_locations_controller_decorator.rb +18 -0
  28. data/app/controllers/spree/base_controller_decorator.rb +13 -0
  29. data/app/helpers/spree/api/api_helpers_decorator.rb +22 -0
  30. data/app/mailers/spree/marketplace_order_mailer.rb +13 -0
  31. data/app/mailers/spree/supplier_mailer.rb +12 -0
  32. data/app/models/ckeditor/asset_decorator.rb +5 -0
  33. data/app/models/spree.rb +5 -0
  34. data/app/models/spree/marketplace_configuration.rb +14 -0
  35. data/app/models/spree/order_decorator.rb +44 -0
  36. data/app/models/spree/payment_decorator.rb +7 -0
  37. data/app/models/spree/product_decorator.rb +52 -0
  38. data/app/models/spree/shipment_decorator.rb +40 -0
  39. data/app/models/spree/stock/splitter/marketplace.rb +47 -0
  40. data/app/models/spree/stock_location_decorator.rb +23 -0
  41. data/app/models/spree/supplier.rb +120 -0
  42. data/app/models/spree/supplier_ability.rb +35 -0
  43. data/app/models/spree/supplier_variant.rb +6 -0
  44. data/app/models/spree/user_decorator.rb +23 -0
  45. data/app/models/spree/variant_decorator.rb +24 -0
  46. data/app/overrides/spree/admin/menus.rb +15 -0
  47. data/app/overrides/spree/admin/products/_form/converted_admin_product_form_right.html.erb.deface +5 -0
  48. data/app/overrides/spree/admin/products/edit/override_rows.html.erb.deface +22 -0
  49. data/app/overrides/spree/admin/stock_locations/_form/add_supplier.html.erb.deface +12 -0
  50. data/app/views/spree/admin/marketplace_settings/edit.html.erb +21 -0
  51. data/app/views/spree/admin/orders/index.html.erb +187 -0
  52. data/app/views/spree/admin/products/_form.html.erb +198 -0
  53. data/app/views/spree/admin/reports/earnings.html.erb +34 -0
  54. data/app/views/spree/admin/shared/_marketplace_settings.html.erb +1 -0
  55. data/app/views/spree/admin/shared/_marketplace_tabs.html.erb +4 -0
  56. data/app/views/spree/admin/shipments/edit.html.erb +24 -0
  57. data/app/views/spree/admin/shipments/index.html.erb +93 -0
  58. data/app/views/spree/admin/suppliers/_form.html.erb +75 -0
  59. data/app/views/spree/admin/suppliers/edit.html.erb +22 -0
  60. data/app/views/spree/admin/suppliers/index.html.erb +68 -0
  61. data/app/views/spree/admin/suppliers/new.html.erb +17 -0
  62. data/app/views/spree/api/shared/_pagination.json.jbuilder +5 -0
  63. data/app/views/spree/api/suppliers/_supplier.json.jbuilder +1 -0
  64. data/app/views/spree/api/suppliers/index.json.jbuilder +4 -0
  65. data/app/views/spree/marketplace_order_mailer/supplier_order.html.erb +119 -0
  66. data/app/views/spree/shared/unauthorized.erb +1 -0
  67. data/app/views/spree/supplier_mailer/welcome.html.erb +53 -0
  68. data/config/locales/en.yml +107 -0
  69. data/config/locales/es.yml +133 -0
  70. data/config/routes.rb +24 -0
  71. data/db/default/spree/marketplace_roles.rb +14 -0
  72. data/db/migrate/20121006073854_create_suppliers.rb +20 -0
  73. data/db/migrate/20130216070944_product_belongs_to_supplier.rb +6 -0
  74. data/db/migrate/20130405005502_stock_locations_belongs_to_supplier.rb +6 -0
  75. data/db/migrate/20130405011127_user_belongs_to_supplier.rb +6 -0
  76. data/db/migrate/20130428063053_add_balanced_token_to_suppliers.rb +7 -0
  77. data/db/migrate/20130510181443_add_supplier_id_to_ckeditor_assets.rb +8 -0
  78. data/db/migrate/20130606220913_add_permalink_to_suppliers.rb +6 -0
  79. data/db/migrate/20140323170638_add_supplier_commission_to_shipments.rb +5 -0
  80. data/db/migrate/20140416184616_migrate_payment_and_commission.rb +7 -0
  81. data/db/migrate/20140529041325_create_spree_supplier_variants.rb +15 -0
  82. data/db/migrate/20171027180043_add_paypal_email_to_suppliers.rb +5 -0
  83. data/db/seeds.rb +8 -0
  84. data/lib/generators/solidus_marketplace/install/install_generator.rb +36 -0
  85. data/lib/solidus_marketplace.rb +6 -0
  86. data/lib/solidus_marketplace/engine.rb +53 -0
  87. data/lib/solidus_marketplace/factories.rb +107 -0
  88. data/lib/solidus_marketplace/version.rb +3 -0
  89. data/lib/spree/permitted_attributes_decorator.rb +18 -0
  90. data/lib/tasks/spree_sample.rake +72 -0
  91. data/log/awesome.log +1 -0
  92. data/script/rails +7 -0
  93. data/solidus_marketplace.gemspec +46 -0
  94. data/spec/features/admin/orders_spec.rb +11 -0
  95. data/spec/features/admin/products_spec.rb +25 -0
  96. data/spec/features/admin/return_authorizations_spec.rb +7 -0
  97. data/spec/features/admin/settings_spec.rb +33 -0
  98. data/spec/features/admin/shipments_spec.rb +80 -0
  99. data/spec/features/admin/stock_management_spec.rb +156 -0
  100. data/spec/features/admin/stock_spec.rb +98 -0
  101. data/spec/features/admin/suppliers_spec.rb +130 -0
  102. data/spec/models/spree/order_decorator_spec.rb +80 -0
  103. data/spec/models/spree/payment_decorator_spec.rb +7 -0
  104. data/spec/models/spree/product_decorator_spec.rb +56 -0
  105. data/spec/models/spree/shipment_decorator_spec.rb +48 -0
  106. data/spec/models/spree/stock/splitter/marketplace_spec.rb +62 -0
  107. data/spec/models/spree/stock_location_decorator_spec.rb +33 -0
  108. data/spec/models/spree/supplier_ability_spec.rb +182 -0
  109. data/spec/models/spree/supplier_spec.rb +123 -0
  110. data/spec/models/spree/supplier_variant_spec.rb +5 -0
  111. data/spec/models/spree/user_decorator_spec.rb +57 -0
  112. data/spec/models/spree/variant_decorator_spec.rb +7 -0
  113. data/spec/spec_helper.rb +91 -0
  114. data/spec/support/ability_helpers.rb +11 -0
  115. data/spec/support/integration_helpers.rb +15 -0
  116. metadata +473 -0
@@ -0,0 +1,24 @@
1
+ Spree::Core::Engine.routes.draw do
2
+
3
+ namespace :admin do
4
+ resource :marketplace_settings
5
+ resources :shipments
6
+ resources :suppliers
7
+ end
8
+
9
+ namespace :api do
10
+ resources :suppliers, only: :index
11
+ end
12
+
13
+ end
14
+
15
+ Spree::Core::Engine.routes.prepend do
16
+ namespace :admin do
17
+ resources :reports do
18
+ collection do
19
+ get :earnings
20
+ post :earnings
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ # create supplier_admin role, new supplier and supplier_admin user
2
+ supplier_admin_role = Spree::Role.where(name: "supplier_admin").first_or_create
3
+ new_supplier = Spree::Supplier.new(name: "Kevin's Guitars", email: "kevinsguitars@example.com")
4
+ supplier_admin = Spree::User.create(email: "supplier_admin@example.com",
5
+ password: "test123",
6
+ password_confirmation: "test123",
7
+ supplier: new_supplier)
8
+ supplier_admin.spree_roles << supplier_admin_role
9
+
10
+ # create marketmaker user
11
+ admin_role = Spree::Role.find_by(name: "admin")
12
+ marketmaker = Spree::User.create(email: "marketmaker@example.com", password: "test123", password_confirmation: "test123")
13
+ marketmaker.spree_roles << admin_role
14
+
@@ -0,0 +1,20 @@
1
+ class CreateSuppliers < ActiveRecord::Migration[4.2]
2
+
3
+ def change
4
+ create_table :spree_suppliers do |t|
5
+ t.boolean :active, default: false, null: false
6
+ t.references :address
7
+ t.decimal :commission_flat_rate, :precision => 8, :scale => 2, :default => 0.0, :null => false
8
+ t.float :commission_percentage, default: 0.0, null: false
9
+ t.string :email
10
+ t.string :name
11
+ t.string :url
12
+ t.datetime :deleted_at
13
+ t.timestamps
14
+ end
15
+ add_index :spree_suppliers, :address_id
16
+ add_index :spree_suppliers, :deleted_at
17
+ add_index :spree_suppliers, :active
18
+ end
19
+
20
+ end
@@ -0,0 +1,6 @@
1
+ class ProductBelongsToSupplier < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :spree_products, :supplier_id, :integer
4
+ add_index :spree_products, :supplier_id
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class StockLocationsBelongsToSupplier < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :spree_stock_locations, :supplier_id, :integer
4
+ add_index :spree_stock_locations, :supplier_id
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class UserBelongsToSupplier < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column Spree.user_class.table_name, :supplier_id, :integer
4
+ add_index Spree.user_class.table_name, :supplier_id
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ class AddBalancedTokenToSuppliers < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :spree_suppliers, :tax_id, :string
4
+ add_column :spree_suppliers, :token, :string
5
+ add_index :spree_suppliers, :token
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class AddSupplierIdToCkeditorAssets < ActiveRecord::Migration[4.2]
2
+ if table_exists?(:ckeditor_assets)
3
+ def change
4
+ add_column :ckeditor_assets, :supplier_id, :integer
5
+ add_index :ckeditor_assets, :supplier_id
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ class AddPermalinkToSuppliers < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :spree_suppliers, :slug, :string
4
+ add_index :spree_suppliers, :slug, unique: true
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddSupplierCommissionToShipments < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :spree_shipments, :supplier_commission, :decimal, precision: 8, scale: 2, default: 0.0, null: false
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class MigratePaymentAndCommission < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :spree_payments, :payable_id, :integer
4
+ add_column :spree_payments, :payable_type, :string
5
+ add_index :spree_payments, [:payable_id, :payable_type]
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ class CreateSpreeSupplierVariants < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :spree_supplier_variants do |t|
4
+ t.belongs_to :supplier, index: true
5
+ t.belongs_to :variant, index: true
6
+ t.decimal :cost
7
+
8
+ t.timestamps
9
+ end
10
+ Spree::Product.where.not(supplier_id: nil).each do |product|
11
+ product.add_supplier! product.supplier_id
12
+ end
13
+ remove_column :spree_products, :supplier_id
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ class AddPaypalEmailToSuppliers < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :spree_suppliers, :paypal_email, :string
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ # Loads seed data out of default dir
2
+ default_path = File.join(File.dirname(__FILE__), 'default')
3
+ %w(
4
+ marketplace_roles
5
+ ).each do |seed|
6
+ puts "Loading seed file: #{seed}"
7
+ require_relative "default/spree/#{seed}"
8
+ end
@@ -0,0 +1,36 @@
1
+ module SolidusMarketplace
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :auto_run_migrations, :type => :boolean, :default => false
5
+
6
+ def add_javascripts
7
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_marketplace\n"
8
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_marketplace\n"
9
+ end
10
+
11
+ def add_stylesheets
12
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_marketplace\n", :before => /\*\//, :verbose => true
13
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_marketplace\n", :before => /\*\//, :verbose => true
14
+ end
15
+
16
+ def include_seed_data
17
+ seed_file = "db/seeds.rb"
18
+ content = "SolidusMarketplace::Engine.load_seed if defined?(SolidusMarketplace)"
19
+ append_file(seed_file, content) unless File.readlines(seed_file).last == content
20
+ end
21
+
22
+ def add_migrations
23
+ run 'bundle exec rake railties:install:migrations FROM=solidus_marketplace'
24
+ end
25
+
26
+ def run_migrations
27
+ run_migrations = options[:auto_run_migrations] || ENV['AUTO_RUN_MIGRATIONS'] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
28
+ if run_migrations
29
+ run 'bundle exec rake db:migrate'
30
+ else
31
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,6 @@
1
+ require 'durable_decorator'
2
+ require 'sass/rails'
3
+ require 'spree_api'
4
+ require 'spree_backend'
5
+ require 'spree_core'
6
+ require 'solidus_marketplace/engine'
@@ -0,0 +1,53 @@
1
+ module SolidusMarketplace
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'solidus_marketplace'
6
+
7
+ config.autoload_paths += %W(#{config.root}/lib)
8
+
9
+ # use rspec for tests
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
13
+
14
+ initializer 'solidus_marketplace.custom_splitters', after: 'spree.register.stock_splitters' do |app|
15
+ app.config.spree.stock_splitters << Spree::Stock::Splitter::Marketplace
16
+ end
17
+
18
+ initializer "solidus_marketplace.preferences", before: :load_config_initializers do |app|
19
+ SolidusMarketplace::Config = Spree::MarketplaceConfiguration.new
20
+ end
21
+
22
+ initializer "solidus_marketplace.menu", before: :load_config_initializers do |app|
23
+ Spree::Backend::Config.configure do |config|
24
+ config.menu_items << Spree::BackendConfiguration::MenuItem.new(
25
+ [:stock_locations],
26
+ 'globe',
27
+ condition: -> { can?(:index, Spree::StockLocation) },
28
+ )
29
+
30
+ config.menu_items << Spree::BackendConfiguration::MenuItem.new(
31
+ [:suppliers],
32
+ 'home',
33
+ condition: -> { can?(:index, Spree::Supplier) },
34
+ )
35
+
36
+ config.menu_items << Spree::BackendConfiguration::MenuItem.new(
37
+ [:shipments],
38
+ 'plane',
39
+ condition: -> { can?(:index, Spree::Shipment) },
40
+ )
41
+ end
42
+ end
43
+
44
+ def self.activate
45
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
46
+ Rails.configuration.cache_classes ? require(c) : load(c)
47
+ end
48
+ Spree::Ability.register_ability(Spree::SupplierAbility)
49
+ end
50
+
51
+ config.to_prepare &method(:activate).to_proc
52
+ end
53
+ end
@@ -0,0 +1,107 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :order_from_supplier, parent: :order do
4
+ bill_address
5
+ ship_address
6
+
7
+ transient do
8
+ line_items_count 5
9
+ end
10
+
11
+ after(:create) do |order, evaluator|
12
+ supplier = create(:supplier)
13
+ product = create(:product)
14
+ product.add_supplier! supplier
15
+ # product.stock_items.where(variant_id: product.master.id).first.adjust_count_on_hand(10)
16
+
17
+ product_2 = create(:product)
18
+ product_2.add_supplier! create(:supplier)
19
+
20
+ create_list(:line_item, evaluator.line_items_count,
21
+ order: order,
22
+ variant: product_2.master
23
+ )
24
+ order.line_items.reload
25
+
26
+ create(:shipment, order: order, stock_location: supplier.stock_locations.first)
27
+ order.shipments.reload
28
+
29
+ order.recalculate
30
+ end
31
+
32
+ factory :completed_order_from_supplier_with_totals do
33
+ state 'complete'
34
+
35
+ after(:create) do |order|
36
+ order.refresh_shipment_rates
37
+ order.update_column(:completed_at, Time.now)
38
+ end
39
+
40
+ factory :order_from_supplier_ready_to_ship do
41
+ payment_state 'paid'
42
+ shipment_state 'ready'
43
+
44
+ after(:create) do |order|
45
+ create(:payment, amount: order.total, order: order, state: 'completed')
46
+ order.shipments.each do |shipment|
47
+ shipment.inventory_units.each { |u| u.update_column('state', 'on_hand') }
48
+ shipment.update_column('state', 'ready')
49
+ end
50
+ order.reload
51
+ end
52
+
53
+ factory :shipped_order_from_supplier do
54
+ after(:create) do |order|
55
+ order.shipments.each do |shipment|
56
+ shipment.inventory_units.each { |u| u.update_column('state', 'shipped') }
57
+ shipment.update_column('state', 'shipped')
58
+ end
59
+ order.reload
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ factory :supplier, :class => Spree::Supplier do
67
+ sequence(:name) { |i| "Big Store #{i}" }
68
+ email { FFaker::Internet.email }
69
+ url "http://example.com"
70
+ address
71
+ commission_flat_rate 0.0
72
+ commission_percentage 10.0
73
+ # Creating a stock location with a factory instead of letting the model handle it
74
+ # so that we can run tests with backorderable defaulting to true.
75
+ before :create do |supplier|
76
+ supplier.stock_locations << build(:stock_location, name: supplier.name, supplier: supplier)
77
+ end
78
+
79
+ factory :supplier_with_commission do
80
+ commission_flat_rate 0.5
81
+ commission_percentage 10
82
+ end
83
+ end
84
+
85
+ factory :supplier_user, parent: :user do
86
+ supplier
87
+ end
88
+
89
+ factory :supplier_admin_role, parent: :role do
90
+ name "supplier_admin"
91
+ end
92
+
93
+ factory :supplier_admin, parent: :user do
94
+ supplier
95
+
96
+ after :create do |user|
97
+ user.spree_roles << create(:supplier_admin_role)
98
+ end
99
+ end
100
+
101
+ factory :variant_with_supplier, parent: :variant do
102
+ after :create do |variant|
103
+ variant.product.add_supplier! create(:supplier)
104
+ end
105
+ end
106
+
107
+ end
@@ -0,0 +1,3 @@
1
+ module SolidusMarketplace
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,18 @@
1
+ Spree::PermittedAttributes.class_eval do
2
+ @@supplier_attributes = [
3
+ :id,
4
+ :address_id,
5
+ :commission_flat_rate,
6
+ :commission_percentage,
7
+ :email,
8
+ :name,
9
+ :url,
10
+ :deleted_at,
11
+ :tax_id,
12
+ :token,
13
+ :slug,
14
+ :paypal_email
15
+ ]
16
+
17
+ mattr_reader(:supplier_attributes)
18
+ end
@@ -0,0 +1,72 @@
1
+ namespace :spree_sample do
2
+ desc "Create sample marketplace orders"
3
+ task :marketplace_orders => :environment do
4
+ if Spree::Order.count == 0
5
+ puts "Please run `rake spree_sample:load` first to create products and orders"
6
+ exit
7
+ end
8
+
9
+ if Spree::Supplier.count == 0
10
+ puts "Please run `rake spree_sample:suppliers` first to create suppliers"
11
+ exit
12
+ end
13
+
14
+ count = 0
15
+ @orders = Spree::Order.complete.includes(:line_items).all
16
+ @suppliers = Spree::Supplier.all
17
+
18
+ puts "Linking existing line items to suppliers"
19
+ Spree::LineItem.all.each do |li|
20
+ print "*" if li.product.add_supplier! @suppliers.shuffle.first.id and li.save
21
+ end
22
+ puts
23
+
24
+ puts "Creating marketplace orders for existing orders"
25
+ Spree::Order.all.each do |order|
26
+ print "*" if order.finalize!
27
+ end
28
+ puts
29
+ end
30
+
31
+ desc "Create sample suppliers and randomly link to products"
32
+ task :suppliers => :environment do
33
+ old_send_value = SolidusMarketplace::Config[:send_supplier_email]
34
+ SolidusMarketplace::Config[:send_supplier_email] = false
35
+
36
+ @usa = Spree::Country.find_by_iso("US")
37
+ @ca = @usa.states.find_by_abbr("CA")
38
+
39
+ count = Spree::Supplier.count
40
+ puts "Creating Suppliers..."
41
+ 5.times{|i|
42
+ name = "Supplier #{count + i + 1}"
43
+ supplier = Spree::Supplier.new(:name => name,
44
+ :email => "#{name.parameterize}@example.com",
45
+ :url => "http://example.com")
46
+ supplier.build_address(:firstname => name, :lastname => name,
47
+ :address1 => "100 State St",
48
+ :city => "Santa Barbara", :zipcode => "93101",
49
+ :state_id => @ca.id, :country_id => @usa.id,
50
+ :phone => '1234567890')
51
+ print "*" if supplier.save
52
+ }
53
+ puts
54
+ puts "#{Spree::Supplier.count - count} suppliers created"
55
+
56
+ puts "Randomly linking Products & Suppliers..."
57
+
58
+ @supplier_ids = Spree::Supplier.pluck(:id).shuffle
59
+ @products = Spree::Product.all
60
+ count = 0
61
+
62
+ @products.each do |product|
63
+ product.add_supplier! Spree::Supplier.find(@supplier_ids[rand(@supplier_ids.length)])
64
+ product.save
65
+ count += 1
66
+ print "*"
67
+ end
68
+ puts
69
+ puts "#{count} products linked."
70
+ SolidusMarketplace::Config[:send_supplier_email] = old_send_value
71
+ end
72
+ end