This commit is contained in:
Adrian Hinz 2018-04-22 00:08:01 +02:00
parent a90aee5f27
commit 986e6cdeb4
1 changed files with 17 additions and 22 deletions

View File

@ -1,21 +1,16 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'development' ENV['RAILS_ENV'] ||= 'development'
require File.dirname(__FILE__) + '/../config/environment' require File.dirname(__FILE__) + '/../config/environment'
# import categories data from old presta shop # import categories data from old presta shop
# category_products from prestashop datapase # category_products from prestashop datapase
class PsCategoryProduct < ApplicationRecord class PsCategoryProduct < ApplicationRecord
self.table_name = 'ps_category_product' self.table_name = 'ps_category_product'
establish_connection :prestashop_old establish_connection :prestashop_old
end end
# Catgories_Products in new database # Catgories_Products in new database
class CategoriesProduct < ApplicationRecord class CategoriesProduct < ApplicationRecord
end end
pcps = PsCategoryProduct.all pcps = PsCategoryProduct.all
pcps.each do |pcp| pcps.each do |pcp|
CategoriesProduct.create(category_id: pcp.id_category, CategoriesProduct.create(category_id: pcp.id_category,
product_id: pcp.id_product) product_id: pcp.id_product)