Holly used to eat chicken poop, we had to put the chickens in a seperate part of the garden so she doesn't have access to the poop. I think that's the simplest and most effective solution.
Alternatively you could try teaching a really strong "leave it" and then only take your dog out on lead and every time he/she goes for the poop cue her/him to "leave it". If he/she get's told to "leave it" everytime it tries to eat the poop then he/she might eventually realize that you don't want her/him to eat the poop. I don't know how well it would work and I didn't try it with Holly but you could give it a try.
Holly also eats grass, when she was younger she ate
a lot of grass. She ate it at home and on walks and she ate lawn clippings at the park. I was starting to get a little worried and would discourage her from eating it but then she seemed to grow out of it. She still does eat grass but not anywhere near as much as she used to.
How old is your dog and how mcuh grass is he/she eating?
Holly also loves cat and horse poop so that could be something to watch out for if your dog is anything like mine