Two brothers who slashed an off-duty police officer with a machete as he intervened in a robbery have been sentenced to seven years in prison.