I plan to use a photo electric sensor to count the bottles
The first thing that I notice is that the code does not count the bottles. It will do exactly the same thing whether there are any bottles passing the sensor or not.
You need to read the sensor output, add one to the count when a bottle is detected then act when the count reaches two. That is not what the code does at the moment.