bug fix in import from ps files

This commit is contained in:
Adrian Hinz 2018-04-21 23:53:59 +02:00
parent b90d401155
commit 95b5732512
4 changed files with 29 additions and 30 deletions

View File

@ -1,5 +1,4 @@
#!/usr/bin/env ruby
# encoding: UTF-8
ENV["RAILS_ENV"] ||= "development"
require File.dirname(__FILE__) + "/../config/environment"
@ -22,7 +21,7 @@ for pcl in pcls
if category.blank?
pc = PsCategory.where('id_category = ?',pcl.id_category).first
if !pc.blank?
cat = Category.new(parent_id: pc.id_parent, level_depth: pc.level_depth, active: pc.active, name: pcl.name, created_by: current_admin.id, updated_by: current_admin.id)
cat = Category.new(parent_id: pc.id_parent, level_depth: pc.level_depth, active: pc.active, name: pcl.name, created_by: 1, updated_by: 1)
cat.id = pc.id_category
cat.save
end

View File

@ -14,7 +14,7 @@ end
ps_images = PsImage.order('id_image')
path = "#{Rails.root}/public/tmp/original/"
for pi in ps_images
ps_images.each do |pi|
file = "#{path}#{pi.id_product}-#{pi.id_image}.jpg"
puts "#{file} - #{File.exist?(file)}"
if File.exist?(file)

View File

@ -20,9 +20,9 @@ pcls.each do |pcl|
product = Product.where(id: pcl.id_product).first
if product.blank?
pc = PsProduct.where('id_product = ?', pcl.id_product).first
if !pc.blank?
unless pc.blank?
prod = Product.new(description: pcl.description, description_short: ActionController::Base.helpers.strip_tags(pcl.description_short), default_category_id: pc.id_category_default,
price: pc.price, quantity: pc.quantity, active: pc.active, name: pcl.name, created_by: current_admin.id, updated_by: current_admin.id)
price: pc.price, quantity: pc.quantity, active: pc.active, name: pcl.name, created_by: 1, updated_by: 1)
prod.id = pc.id_product
prod.save
end

View File

@ -93,7 +93,7 @@ Rails.application.configure do
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
@ -106,10 +106,10 @@ Rails.application.configure do
full_path = Rails.application.assets.resolve(path).to_path
app_assets_path = Rails.root.join('app', 'assets').to_path
if full_path.starts_with? app_assets_path
puts "including asset: " + full_path
puts 'including asset: ' + full_path
true
else
puts "excluding asset: " + full_path
puts 'excluding asset: ' + full_path
false
end
else