"Training" makes your pet want to be next to you more. (Note the effect diminishes the more times your pet enters an adjacent square.) So the more highly your pet is trained, the easier it is to lure it into a shop, and if you go and wait outside the shop the better the chance your pet will come to you and drop any shoplifted item outside the shop instead of inside.

If you're patient and powerful enough to defeat any hostiles who show up in the meantime, your pet will eventually clean out the shop (except for cursed items and anything sharing a square with a cursed item) even if you haven't really bothered with training.

PsyMar: Almost correct but the willingness to apport (drop items next to you) isn't increased by that. You will have to throw your pet the food as soon as possible after it drops an item next to you. Details can be found at http://www.helsinki.fi/~vviitane/spoilers/pets