Every retailer will have a disclaimer that says something like "We are not required to honour pricing errors" or some such on their website or flyers.
The reason that this is legal is that contracts are based on offer and acceptance. The price on an item is not considered the offer. The offer is made when you take an item to the till and YOU offer to buy, they can then accept or decline.
Having said that, a really good retailer will honour the price and say "damn, our mistake and you're getting a hell of a deal" then change the price. To me that is excellent customer service.