When you sell your products to a wholesaler or retailer (Amazon, Target, Borders Books, Autozone, etc.), they will have you supply them or will have you fill out a product information sheet.
The things that you put on that sheet is your company and product information including the UPC/EAN code number for each product.
Then, the wholesaler or retailer enters this information in their information systems computer. This computer ties into the registers at the front of the store. The cashier scans your item and the information comes up. Every time an item is scanned and sold, it deducts the number of items sold from their inventory.