The easiest way would be to use a 12V/24V DC pump with a 12V/24V AC power supply and a 12V/24V nominal (18V/36V peak) solar panel in parallel with 2 blocking diodes. When there is enough sun, the panel will deliver more voltge than the power supply which won't have to supply any current.