You can start by making sure you get his attention with treats, when there are kids or exciting stuff happening outside. I believe that it's a good idea to reinforce him into a calm state where he doesn't prance around or whines, where you get his attention inside the house and reward him with a treat once he sits down. You can then raise the training level by making him not just sit, but also lay down, and make sure that he calms down a bit before you reward him for his calm state. With all kind of training with dogs it just requires patience, practice, consistency... do this for a few days, maybe dedicate 10 minutes to each session where he starts to whine, don't get frustrated if the behavior doesn't go away on the fly, it might take a couple of sessions, as long as you get him to calm down once or twice per session the number of times you need to calm him down will reduce over time for sure. You will notice that by the time you take your training to a public area such as the store how you describe you will have a much calmer dog that will probably won't need a lot of effort because you will notice that the dog will most likely be calm because of the behaviors he learned while being in the house. And just in case for public areas: You can start to determine if the bad behavior is cause by "you" the master leaving his sight by having someone stay outside with him for a bit to see how he reacts to you leaving.