mercator_legacy_importer 0.0.1 → 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +22 -1
- data/app/models/mercator_legacy_importer/asset.rb +6 -3
- data/app/models/mercator_legacy_importer/attachable.rb +7 -4
- data/app/models/mercator_legacy_importer/category.rb +10 -7
- data/app/models/mercator_legacy_importer/category_translation.rb +9 -6
- data/app/models/mercator_legacy_importer/cms_node.rb +8 -5
- data/app/models/mercator_legacy_importer/cms_node_translation.rb +9 -6
- data/app/models/mercator_legacy_importer/connector.rb +8 -5
- data/app/models/mercator_legacy_importer/content.rb +7 -4
- data/app/models/mercator_legacy_importer/content_item.rb +7 -4
- data/app/models/mercator_legacy_importer/country.rb +6 -3
- data/app/models/mercator_legacy_importer/page_template.rb +9 -6
- data/app/models/mercator_legacy_importer/product.rb +12 -9
- data/app/models/mercator_legacy_importer/product_overview_property.rb +6 -3
- data/app/models/mercator_legacy_importer/product_property.rb +8 -5
- data/app/models/mercator_legacy_importer/product_relation.rb +6 -3
- data/app/models/mercator_legacy_importer/product_supply.rb +6 -3
- data/app/models/mercator_legacy_importer/product_translation.rb +10 -7
- data/app/models/mercator_legacy_importer/property.rb +12 -9
- data/app/models/mercator_legacy_importer/property_translation.rb +9 -6
- data/app/models/mercator_legacy_importer/recommendation.rb +9 -7
- data/app/models/mercator_legacy_importer/recommendation_translation.rb +10 -7
- data/app/models/mercator_legacy_importer/user.rb +6 -3
- data/app/views/layouts/mercator_legacy_importer/application.html.erb +10 -11
- data/db/migrate/20131202162757_add_legacy_ids.rb +10 -6
- data/lib/mercator_legacy_importer/version.rb +2 -2
- data/lib/tasks/categories.rake +43 -0
- data/lib/tasks/categorizations.rake +43 -0
- data/lib/tasks/category_images.rake +42 -34
- data/lib/tasks/cms_node_images.rake +91 -81
- data/lib/tasks/content_elements.rake +66 -44
- data/lib/tasks/countries.rake +16 -10
- data/lib/tasks/features.rake +25 -17
- data/lib/tasks/page_template.rake +16 -9
- data/lib/tasks/product_images.rake +25 -8
- data/lib/tasks/product_relations.rake +21 -13
- data/lib/tasks/products.rake +52 -39
- data/lib/tasks/properties.rake +45 -36
- data/lib/tasks/recommendations.rake +30 -19
- data/lib/tasks/remaining_assets.rake +34 -26
- data/lib/tasks/remaining_images.rake +34 -26
- data/lib/tasks/supply_relations.rake +23 -13
- data/lib/tasks/unlinked_content_items.rake +24 -18
- data/lib/tasks/users.rake +43 -10
- data/lib/tasks/webpages.rake +34 -0
- metadata +30 -39
- data/app/helpers/mercator_legacy_importer/application_helper.rb +0 -4
- data/config/database.yml +0 -13
- data/db/migrate/20131202164442_products_add_legacy_id.rb +0 -9
- data/db/migrate/20140103154252_add_legacy_id_to_page.rb +0 -9
- data/db/migrate/20140103161205_add_legacy_id_to_page_template.rb +0 -9
- data/db/migrate/20140104094617_add_legacy_id_to_feature.rb +0 -9
- data/db/migrate/20140107090420_add_legacy_id_to_content_elements.rb +0 -9
- data/lib/tasks/categories.rb +0 -32
- data/lib/tasks/categorizations.rb +0 -35
- data/lib/tasks/mercator_legacy_importer_tasks.rake +0 -34
- data/lib/tasks/pages.rake +0 -27
- data/lib/tasks/unlinked_content_elements.rake +0 -60
data/lib/tasks/countries.rake
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
|
2
|
-
puts "\n\nCountries:"
|
1
|
+
# encoding: utf-8
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
namespace :legacy_import do
|
4
|
+
# starten als: 'bundle exec rake legacy_import:countries
|
5
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:countries RAILS_ENV=production'
|
6
|
+
desc "Import countries from legacy webshop"
|
7
|
+
task :countries => :environment do
|
8
|
+
|
9
|
+
MercatorLegacyImporter::Country.all.each do |legacy_country|
|
10
|
+
country = Country.find_or_initialize_by_name_de(legacy_country.country_name)
|
11
|
+
if country.update_attributes(name_en: legacy_country.country_name,
|
12
|
+
code: legacy_country.country_a2,
|
13
|
+
legacy_id: legacy_country.id)
|
14
|
+
print "C"
|
15
|
+
else
|
16
|
+
puts "\nFAILURE: Country: " + country.errors.first.to_s
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
data/lib/tasks/features.rake
CHANGED
@@ -1,21 +1,29 @@
|
|
1
|
-
|
2
|
-
puts "\n\nFeatures:"
|
1
|
+
# encoding: utf-8
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
namespace :legacy_import do
|
4
|
+
# starten als: 'bundle exec rake legacy_import:features
|
5
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:features RAILS_ENV=production'
|
6
|
+
desc "Import features from legacy webshop"
|
7
|
+
task :features => :environment do
|
8
|
+
|
9
|
+
puts "\n\nFeatures:"
|
10
|
+
|
11
|
+
n=1
|
12
|
+
MercatorLegacyImporter::ProductOverviewProperty.all.each do |legacy_product_overview_property|
|
13
|
+
legacy_product = Product.find_by_legacy_id(legacy_product_overview_property.product_id)
|
14
|
+
unless legacy_product
|
15
|
+
puts "\nFAILURE: Product not found: " + legacy_product_overview_property.product_id.to_s
|
16
|
+
next
|
17
|
+
end
|
18
|
+
feature = Feature.create(text_de: legacy_product_overview_property.description,
|
19
|
+
position: ( legacy_product_overview_property.order || n = n + 1 ),
|
20
|
+
product_id: legacy_product.id,
|
21
|
+
legacy_id: legacy_product_overview_property.id)
|
22
|
+
if feature.save
|
23
|
+
print "F"
|
24
|
+
else
|
25
|
+
puts "\nFAILURE: Feature: " + feature.errors.first.to_s
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
@@ -1,13 +1,20 @@
|
|
1
|
-
|
2
|
-
puts "\n\nPage Templates:"
|
1
|
+
# encoding: utf-8
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
namespace :legacy_import do
|
4
|
+
# starten als: 'bundle exec rake legacy_import:page_templates
|
5
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:page_templates RAILS_ENV=production'
|
6
|
+
desc "Import page_templates from legacy webshop"
|
7
|
+
task :page_templates => :environment do
|
8
|
+
puts "\n\nPage Templates:"
|
9
|
+
|
10
|
+
MercatorLegacyImporter::PageTemplate.all.each do |legacy_page_template|
|
11
|
+
if page_template = PageTemplate.create(name: legacy_page_template.name,
|
12
|
+
content: legacy_page_template.content,
|
13
|
+
legacy_id: legacy_page_template.id)
|
14
|
+
print "T"
|
15
|
+
else
|
16
|
+
puts "\nFAILURE: PageTemplate: " + page_template.errors.first.to_s
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
@@ -1,11 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
namespace :legacy_import do
|
4
|
+
# starten als: 'bundle exec rake legacy_import:product_images
|
5
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:product_images RAILS_ENV=production'
|
6
|
+
desc "Import product_images from legacy webshop"
|
7
|
+
task :product_images => :environment do
|
8
|
+
|
9
|
+
require 'net/http'
|
10
|
+
puts "\n\nProduct Images:"
|
11
|
+
|
12
|
+
Net::HTTP.start("www.iv-shop.at") do |http|
|
13
|
+
MercatorLegacyImporter::Product.all.each do |legacy_product|
|
14
|
+
unless legacy_product.image_file_name || legacy_product.overview_file_name
|
15
|
+
print "x"
|
16
|
+
next
|
17
|
+
end
|
4
18
|
|
5
|
-
Net::HTTP.start("www.iv-shop.at") do |http|
|
6
|
-
Legacy::Product.all.each do |legacy_product|
|
7
|
-
if legacy_product.image_file_name || legacy_product.overview_file_name
|
8
19
|
product = Product.find_by_legacy_id(legacy_product.id)
|
20
|
+
if product.photo_file_name.present?
|
21
|
+
print "✔"
|
22
|
+
next
|
23
|
+
end
|
24
|
+
|
9
25
|
filename = "/system/images/" + legacy_product.id.to_s +
|
10
26
|
"/original/" + legacy_product.image_file_name.presence ||
|
11
27
|
legacy_product.overview_file_name
|
@@ -13,13 +29,14 @@ def import_product_images
|
|
13
29
|
data.class.class_eval { attr_accessor :original_filename }
|
14
30
|
data.original_filename = legacy_product.image_file_name.presence || legacy_product.overview_file_name
|
15
31
|
product.photo = data
|
32
|
+
product.photo_content_type = MIME::Types.type_for(data.original_filename).first.content_type
|
33
|
+
|
16
34
|
if product.save
|
17
35
|
print "P"
|
18
36
|
else
|
19
37
|
puts "\nFAILURE: Image: " + product.errors.first.to_s
|
38
|
+
# If image is missing on server, we get probable a content type mismatch error, e.g. html (error page) instead of png (image)
|
20
39
|
end
|
21
|
-
else
|
22
|
-
print "."
|
23
40
|
end
|
24
41
|
end
|
25
42
|
end
|
@@ -1,21 +1,29 @@
|
|
1
|
-
|
2
|
-
puts "\n\nProductRelations:"
|
1
|
+
# encoding: utf-8
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
namespace :legacy_import do
|
4
|
+
# starten als: 'bundle exec rake legacy_import:product_relations
|
5
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:product_relations RAILS_ENV=production'
|
6
|
+
desc "Import product relations from legacy webshop"
|
7
|
+
task :product_relations => :environment do
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
puts "\n\nProductRelations:"
|
10
|
+
|
11
|
+
MercatorLegacyImporter::ProductRelation.all.each do |legacy_product_relation|
|
12
|
+
if product = Product.find_by(legacy_id: legacy_product_relation.product_id)
|
13
|
+
if related_product = Product.find_by(legacy_id: legacy_product_relation.related_product_id)
|
14
|
+
|
15
|
+
if productrelation = Productrelation.create(product_id: product.id,
|
16
|
+
related_product_id: related_product.id)
|
17
|
+
print "P"
|
18
|
+
else
|
19
|
+
puts "\nFAILURE: Productrelation: " + productrelation.errors.first.to_s
|
20
|
+
end
|
11
21
|
else
|
12
|
-
puts "\
|
22
|
+
puts "\n FAIILURE: Product not found"
|
13
23
|
end
|
14
|
-
else
|
15
|
-
|
24
|
+
else
|
25
|
+
puts "\n FAIILURE: RelatedProduct not found"
|
16
26
|
end
|
17
|
-
else
|
18
|
-
puts "\n FAIILURE: RelatedProduct not found"
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
data/lib/tasks/products.rake
CHANGED
@@ -1,48 +1,61 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Product.all.each do |product|
|
4
|
-
product.delete
|
5
|
-
end
|
6
|
-
print "Products deleted."
|
7
|
-
|
8
|
-
Legacy::Product.all.each do |legacy_product|
|
9
|
-
legacy_product_de = legacy_product.product_translations.german.first
|
10
|
-
legacy_product_en = legacy_product.product_translations.english.first
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'string_extensions'
|
11
3
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
namespace :legacy_import do
|
5
|
+
# starten als: 'bundle exec rake legacy_import:products
|
6
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:products RAILS_ENV=production'
|
7
|
+
desc "Import products from legacy webshop"
|
8
|
+
task :products => :environment do
|
9
|
+
puts "\n\nProducts:"
|
10
|
+
Product.all.each do |product|
|
11
|
+
product.delete
|
16
12
|
end
|
13
|
+
print "Products deleted."
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
description_de = "fehlt"
|
22
|
-
end
|
15
|
+
MercatorLegacyImporter::Product.all.each do |legacy_product|
|
16
|
+
legacy_product_de = legacy_product.product_translations.german.first
|
17
|
+
legacy_product_en = legacy_product.product_translations.english.first
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
if legacy_product_de && legacy_product_de.title.present?
|
20
|
+
title_de = legacy_product_de.title
|
21
|
+
else
|
22
|
+
title_de = legacy_product.name
|
23
|
+
end
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
if legacy_product_de && legacy_product_de.long_description.present?
|
26
|
+
description_de = legacy_product_de.long_description
|
27
|
+
else
|
28
|
+
description_de = "fehlt"
|
29
|
+
end
|
30
|
+
|
31
|
+
if legacy_product_en && legacy_product_en.title.present?
|
32
|
+
title_en = legacy_product_en.title
|
33
|
+
else
|
34
|
+
title_en = legacy_product.name
|
35
|
+
end
|
36
|
+
|
37
|
+
if legacy_product_en && legacy_product_en.long_description.present?
|
38
|
+
description_en = legacy_product_en.long_description
|
39
|
+
else
|
40
|
+
description_en = "missing"
|
41
|
+
end
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
product = Product.create(number: legacy_product.article_number,
|
44
|
+
title_de: title_de,
|
45
|
+
title_en: title_en,
|
46
|
+
description_de: description_de.fix_utf8,
|
47
|
+
description_en: description_en.fix_utf8,
|
48
|
+
legacy_id: legacy_product.id)
|
49
|
+
if product.save
|
50
|
+
print "P"
|
51
|
+
else
|
52
|
+
product.number = legacy_product.id.to_s + " - Duplikat von " + legacy_product.article_number
|
53
|
+
if product.save
|
54
|
+
print "P"
|
55
|
+
else
|
56
|
+
puts "\nFAILURE: Product " + legacy_product.article_number + ": " + product.errors.first.to_s
|
57
|
+
end
|
58
|
+
end
|
46
59
|
end
|
47
60
|
end
|
48
61
|
end
|
data/lib/tasks/properties.rake
CHANGED
@@ -1,44 +1,53 @@
|
|
1
|
-
|
2
|
-
# puts "\n\nProperty Groups and Properties:"
|
3
|
-
# Property.all.each do |property|
|
4
|
-
# property.delete
|
5
|
-
# end
|
6
|
-
# print "Properties deleted."
|
7
|
-
# PropertyGroup.all.each do |property_group|
|
8
|
-
# property_group.delete
|
9
|
-
# end
|
10
|
-
# print "Property Groups deleted."
|
1
|
+
# encoding: utf-8
|
11
2
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
legacy_property_en = legacy_property.property_translations.english.first
|
3
|
+
namespace :legacy_import do
|
4
|
+
# starten als: 'bundle exec rake legacy_import:properties
|
5
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:properties RAILS_ENV=production'
|
6
|
+
desc "Import properties from legacy webshop"
|
7
|
+
task :properties => :environment do
|
18
8
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
9
|
+
puts "\n\nProperty Groups and Properties:"
|
10
|
+
Property.all.each do |property|
|
11
|
+
property.delete
|
12
|
+
end
|
13
|
+
|
14
|
+
print "Properties deleted."
|
15
|
+
PropertyGroup.all.each do |property_group|
|
16
|
+
property_group.delete
|
17
|
+
end
|
18
|
+
print "Property Groups deleted."
|
19
|
+
|
20
|
+
MercatorLegacyImporter::Product.all.each do |legacy_product|
|
21
|
+
product = Product.find_by_legacy_id(legacy_product.id)
|
22
|
+
legacy_product.properties.each do |legacy_property|
|
23
|
+
# next if legacy_property.id < 21050
|
24
|
+
legacy_property_de = legacy_property.property_translations.german.first
|
25
|
+
legacy_property_en = legacy_property.property_translations.english.first
|
26
|
+
|
27
|
+
property_group =
|
28
|
+
PropertyGroup.find_or_initialize_by_name_de_and_product_id(
|
29
|
+
legacy_property_de.group.presence || legacy_property_de.name,
|
30
|
+
product.id)
|
31
|
+
if property_group.update_attributes(name_en: legacy_property_en.group.presence ||
|
32
|
+
legacy_property_en.name,
|
33
|
+
position: 1)
|
34
|
+
print "G"
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
property = Property.create(name_de: legacy_property_de.name,
|
37
|
+
property_group_id: property_group.id,
|
38
|
+
name_en: legacy_property_en.name,
|
39
|
+
description_de: legacy_property.presentation_value,
|
40
|
+
description_en: legacy_property.presentation_value,
|
41
|
+
position: 1,
|
42
|
+
legacy_id: legacy_property.id)
|
43
|
+
if property.save
|
44
|
+
print "p"
|
45
|
+
else
|
46
|
+
puts "\nFAILURE: Property: " + property.errors.first.to_s
|
47
|
+
end
|
37
48
|
else
|
38
|
-
puts "\nFAILURE:
|
49
|
+
puts "\nFAILURE: PropertyGroup: " + property_group.errors.first.to_s
|
39
50
|
end
|
40
|
-
else
|
41
|
-
puts "\nFAILURE: PropertyGroup: " + property_group.errors.first.to_s
|
42
51
|
end
|
43
52
|
end
|
44
53
|
end
|
@@ -1,28 +1,39 @@
|
|
1
|
-
|
2
|
-
puts "\n\nRecommendations:"
|
1
|
+
# encoding: utf-8
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
namespace :legacy_import do
|
4
|
+
# starten als: 'bundle exec rake legacy_import:recommendations
|
5
|
+
# in Produktivumgebungen: 'bundle exec rake legacy_import:recommendations RAILS_ENV=production'
|
6
|
+
desc "Import recommendations from legacy webshop"
|
7
|
+
task :recommendations => :environment do
|
8
|
+
puts "\n\nRecommendations:"
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
Recommendation.all.each do |recommendation|
|
11
|
+
recommendation.delete
|
12
|
+
end
|
13
|
+
print "Recommendations deleted."
|
14
|
+
|
15
|
+
MercatorLegacyImporter::Recommendation.all.each do |legacy_recommendation|
|
16
|
+
legacy_reason_de = legacy_recommendation.recommendation_translations.german.first
|
17
|
+
legacy_reason_en = legacy_recommendation.recommendation_translations.english.first
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
next if legacy_recommendation.from_product_id.nil?
|
20
|
+
if product = Product.find_by(legacy_id: legacy_recommendation.from_product_id)
|
21
|
+
next if legacy_recommendation.for_product_id.blank?
|
22
|
+
if recommendation = Product.find_by(number: legacy_recommendation.for_product_id)
|
23
|
+
if recommendation = Recommendation.create(product_id: product.id,
|
24
|
+
recommended_product_id: recommendation.id,
|
25
|
+
reason_de: legacy_reason_de.description.fix_utf8,
|
26
|
+
reason_en: legacy_reason_en.description.fix_utf8)
|
27
|
+
print "R"
|
28
|
+
else
|
29
|
+
puts "\nFAILURE: Recommendation: " + recommendation.errors.first.to_s
|
30
|
+
end
|
18
31
|
else
|
19
|
-
puts "\
|
32
|
+
puts "\n FAIILURE: Recommended product not found: " + legacy_recommendation.for_product_id
|
20
33
|
end
|
21
|
-
else
|
22
|
-
puts "\n FAIILURE:
|
34
|
+
else
|
35
|
+
puts "\n FAIILURE: Product not found: " + legacy_recommendation.from_product_id.to_s
|
23
36
|
end
|
24
|
-
else
|
25
|
-
puts "\n FAIILURE: Product not found: " + legacy_recommendation.from_product_id.to_s
|
26
37
|
end
|
27
38
|
end
|
28
39
|
end
|