I want to add to your comment, that the problem with Walgreens security in SF is well known, far before the issues with the changes in the law took front and center. I actually had a conversation with a friend about how bad their security was back in 2007. The issue is purely one of store layout and design. They could easily fix that and solve most of the problem.
I feel like criminals are also abundantly aware at this point they won't face prosecution from SF's DA, so feel agency to commit "minor" crimes like this with impunity. But most of the SF stores do have a very old-school layout.
One way to solve the problem, is to put a counter in front of all the merchandise, make everyone use a shopping cart in the app as they walk around the store, allowing you to use your camera to snap images of products you want, or choose from a list, which the app checks and converts to real time inventory, and adds to your cart as needed. Then, check out and pay for it either online or at the counter, and pick up your items. Problem solved.
How would layout stop ransacking that goes intentionally unprosecuted? Looting example in Alameda that seems unrelated to store design: https://youtube.com/watch?v=9ICQDYeAPDE
On this site, people like to look for technical solutions to social problems. "Law enforcement and the courts aren't doing their jobs? No problem, just rearrange the shelves in your shops..."