Skip to content

Instantly share code, notes, and snippets.

@tiagomatos
Created August 12, 2019 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagomatos/0804f7a8cec1a7bc5ae90705df3d6fc3 to your computer and use it in GitHub Desktop.
Save tiagomatos/0804f7a8cec1a7bc5ae90705df3d6fc3 to your computer and use it in GitHub Desktop.
Duplicated Products (via SKU / name comparison)
store = Store.find_by(code: "XXX")
store.products.all.each do |product|
p "product id: #{product.id} SKU duplicated from #{store.products.where(sku: product.sku).map(&:id)}" if store.products.where(sku: product.sku).size >= 2
p "product id: #{product.id} name duplicated from #{store.products.where(name: product.name).map(&:id)}" if store.products.where(name: product.name).size >= 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment