class Workarea::MagentoMigrator::CatalogCategory
Public Class Methods
categories()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 61 def categories client.query(categories_query).to_a end
categories_content()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 38 def categories_content {home_categories: 9, business_categories: 10, shop_murals_categories: 8}.each do |category_name, id| categories = client.query(content_categories_query(id)).to_a categories_content = categories.map { |cat| { name: cat['name'], slug: cat['url_key'], h1_tag: cat['h1_tag'], bottom_content: (cat['bottom_content'] || ''), description: (cat['description'] || '') } } File.open("#{Rails.root.to_s}/data/#{category_name}.json", "w"){ |f| f.write(JSON.pretty_generate(categories_content)) } end end
categories_query()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 73 def categories_query " #{select_query} and e.children_count = 0 order by e.parent_id asc " end
content_categories_query(parent_id)
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 56 def content_categories_query(parent_id) "SELECT #{select_columns} FROM #{table_name}_entity e #{join_clause} where e.parent_id=#{parent_id} and v19.value=1 order by e.position asc" end
ids_to_include()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 6 def ids_to_include "SELECT distinct(category_id) FROM catalog_category_product " end
import_catagories()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 29 def import_catagories File.open("#{Rails.root.to_s}/data/categories.json", "w"){ |f| f.write(JSON.pretty_generate(categories.to_a)) } File.open("#{Rails.root.to_s}/data/soft_categories.json", "w"){ |f| f.write(JSON.pretty_generate(soft_categories.to_a)) } end
import_content_pages()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 23 def import_content_pages File.open("#{Rails.root.to_s}/data/content_pages.json", "w"){ |f| f.write(JSON.pretty_generate(catalog_category_menu)) } end
select_content_pages_query()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 14 def select_content_pages_query select_query = "SELECT #{select_columns} FROM #{table_name}_entity e #{join_clause} " select_query += "\nwhere e.entity_id not in (#{ids_to_include}) and e.parent_id>1 and e.level >1" end
soft_categories()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 65 def soft_categories client.query(soft_categories_query).to_a end
soft_categories_query()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 69 def soft_categories_query " #{select_query} and e.children_count > 0 order by e.parent_id asc " end
table_name()
click to toggle source
# File lib/workarea/magento_migrator/catalog_category.rb, line 10 def table_name @@table_name ||= 'catalog_category' end