I believe there has been discussion in MilesBuzz! about buying gift cards to other stores (restaurants, bookstores, iTunes, for example) at grocery stores for the purpose of getting grocery store bonuses. I know Krogers here sell all sorts of gift cards, but I haven't tried it before. I don't see why your plan wouldn't work though.
In the past, I have bought Walmart/Sam's Club gift cards at Walmart (to get miles at Sam's Club) and had no problem with the mileage posting.