Traders have been given a Monday deadline to buy crops from farmers at an approved price, and not below.
If this does not happen, Mr. Magufuli said he will send dozens of military trucks to collect the entire crop.
Cashew nut exports are a major foreign-currency earner for Tanzania.
Farmers have for weeks been refusing to sell their harvests, arguing that the private traders’ offers are too low.
On Saturday, Mr. Magufuli accused traders of attempting to rip off thousands of farmers and ordered them to increase their price offers to around $1.3 (£1; €1.15) per kilogram (2.2 pounds).
The president says he is working to ensure thousands of farmers get a fair price for their cashew nuts and also so that the country does not miss out on vital export earnings.
He added that if he is forced to deploy the army to round up the supplies of cashew nuts, his government will buy them.
Following the sackings of the agriculture minister, Charles Tizeba, and the trade and investment minister, Charles Mwijage, Mr. Magufuli appointed two other ministers and four deputies.
He has also disbanded the Cashewnut Board of Tanzania (CBT) and has revoked the appointment of the board chair, Anna Abdallah.
This is not the first time that the country has suffered such a crisis.
In 2013,riots by cashew nut farmers and other protesters in southern Tanzanialed to some 20 properties being burned down.
The trouble began after traders began paying farmers less for their crop than had been previously agreed. As a result, police were deployed to the region to stop further unrest.