Quickleaf
Legend
My go-to solution is the epic-level shopkeeper, but I've got to admit it's pretty ham-handed. How else do you keep a gang of wild murderhobos from taking all of a 3rd level commoner's worldly goods and breaking your economy?
While I agree with much of what's been said, if you do wish to have magic shops in your game, I remember reading a good example of one in Faction War. While it's a much-reviled AD&D2e Planescape adventure, it has one saving grace: Alluvius Ruskin's magic shop is exactly the sort of dangerous unpredictable mini-dungeon I'd expect PCs to face if attempting to loot a magic shop.