|
|
@@ -473,3 +473,20 @@ class Product < ActiveRecord::Base
|
|
|
puts 'termine'
|
|
|
end
|
|
|
end
|
|
|
+
|
|
|
+def self.gen_barcode_img_for_existing_barcodes
|
|
|
+ products = Product.activos_children
|
|
|
+ counter = 0
|
|
|
+ products.each do |product|
|
|
|
+ if product.barcode?
|
|
|
+ unless File.file?(Rails.public_path.join('barcodes', "#{product.barcode}.png"))
|
|
|
+ save_path = Rails.public_path.join('barcodes', "#{product.barcode}.png")
|
|
|
+ File.open(save_path, 'wb') { |f| f.write Barby::Code39.new(product.barcode).to_png(height: 50, margin: 5) }
|
|
|
+ counter += 1;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ puts "***** NO TIENE BARCODE! #{product.id}"
|
|
|
+ end
|
|
|
+ end
|
|
|
+ puts "TERMINÉ, generé: #{counter} imagenes de barcode"
|
|
|
+end
|