One way is starving. You stop feeding food A and only feed food B until they would eat food B, and if they still refuse after X # days you give in and feed food A just a little then resume the starvation. this can work for bigger and healthier fish
Another way other people suggested is to feed food A marinated with food B for a while, then slowly feed both foods mixed at the same time and slowly reduce the amount of food A and increase the amount of food B until they feed on food B alone, this can take a long time but is less devastating for your fish
I am sure others will chime in from their exp too good luck!