From a90aee5f2761ed08959e3d45ef0cdbeabe319d41 Mon Sep 17 00:00:00 2001 From: Adrian Hinz Date: Sun, 22 Apr 2018 00:05:01 +0200 Subject: [PATCH] added import for category products --- bin/import_category_product_from_ps.rb | 22 ++++++++++++++++++++++ bin/import_images_from_ps.rb | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 bin/import_category_product_from_ps.rb diff --git a/bin/import_category_product_from_ps.rb b/bin/import_category_product_from_ps.rb new file mode 100644 index 0000000..af347ef --- /dev/null +++ b/bin/import_category_product_from_ps.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +ENV['RAILS_ENV'] ||= 'development' +require File.dirname(__FILE__) + '/../config/environment' + +# import categories data from old presta shop + +# category_products from prestashop datapase +class PsCategoryProduct < ApplicationRecord + self.table_name = 'ps_category_product' + establish_connection :prestashop_old +end + +# Catgories_Products in new database +class CategoriesProduct < ApplicationRecord +end + +pcps = PsCategoryProduct.all + +pcps.each do |pcp| + CategoriesProduct.create(category_id: pcp.id_category, + product_id: pcp.id_product) +end diff --git a/bin/import_images_from_ps.rb b/bin/import_images_from_ps.rb index 1ccf13d..e1ab940 100644 --- a/bin/import_images_from_ps.rb +++ b/bin/import_images_from_ps.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 ENV["RAILS_ENV"] ||= "development" require File.dirname(__FILE__) + "/../config/environment"