All magic items are cursed until paid for. Sorta like those tags you put on clothing that set off the alarms when you walk out? Yeah same deal. Attempting to decurse the item without the shopkeep causes the item to explode.
Alternatively, all magic items are just illusions cast of a stock that is stored in an extra-dimensional space accessible only to the shopkeep. Sure, it's possible to travel to this extra-dimensional space if you can find the location, but it's full of dangerous monsters and traps (it's basically an epic dungeon).
Or maybe the store has a deadmans switch keyed to the shopkeep. If they die, the entire store goes on super-magical lockdown.
I don't typically like magic item stores, but I understand that they are a somewhat reasonable result of high-level high-magic games where magic items are found in loot, moreso if that loot is random. I like to tailor my magic items to my players, but there is still a chance for loss or replacement, and sometimes a merchant may only be willing to trade the Key to the Mcguffin for that really cool sword you have. So logically, magical trade does exist and "magic item shops" are more a result of magic item collectors (IE: rich people with too much time on their hands) who die or run short on cash. Ever seen an estate sale for a really old really wealthy person? Yeah, that's where Magic Item Shoppeees, with too many p's and too many e's are born.