Dairy farmers and processors have struck a deal "in principle" over milk prices following lengthy meetings today at the Royal Welsh Show.

After face-to-face talks, the two sides have agreed to sign up to a new voluntary code of practice.

Under the new terms, companies buying milk, such as supermarkets, would have to give farmers a "sensible" warning period before changing their prices. It is hoped that this would give farmers enough time to withdraw from any deals.

The agreement comes after farmers blockaded several dairy factories around the UK in protest of how much they are paid for their milk.

But National Farming Union Cymru Deputy President Stephen James said that there's still a long way to go to solve the dairy farming issue:

Today’s announcement gave some hope for the long term but it did not solve the dairy farming issues of today. This agreement will give us the architecture we need to make sure that we don’t end up with the same dysfunctional markets that are responsible for the dairy crisis we have today.

UK farming minister Jim Paice said the whole industry needs a "shake-up."

A spokesman from the UK Government's Department for Environment, Food, and Rural Affairs (Defra) said:

The final details of the code will now be finalised by all parties by the end of August. As part of the agreement, individual farmers can negotiate contracts- covering issues such as pricing and notice periods. Farmers will also have the ability to leave contracts "more easily" if they are unhappy with the price they receive.

Earlier today one West Wales farmer directly affected by the milk dispute spoke about the problems dairy farmers have been facing and their fears for the future of the industry.

Back in 1994, the price that we would get for a pint of milk was around 25p per litre. Since then our costs, including fuel prices, have risen dramatically but the price which we receive has not gone up in line with those rises. Many processors and supermarkets are paying dairy farmers less - to keep the price of milk artificially low for shoppers. In the short term that sounds like a great deal for the consumer. But over time it has meant those in the dairy sector are incurring losses. It has had a major effect on us and has resulted in the number of dairy farmers halving within the past 13 years.