Some Protestants object that there is no basis for the Catholic doctrine of the treasury of merits of the saints (about which see here in the Catechism). But this doctrine is really in essence not different from the fact that for the sake of the righteousness of David, his sons enjoyed blessings even when they themselves were wicked:
Yahweh was angry with Solomon because his heart had turned away from Yahweh, God of Israel, who had twice appeared to him and had forbidden him to follow other gods; but he did not carry out Yahweh’s order. Yahweh therefore said to Solomon, ‘Since you have behaved like this and have not kept my covenant or the laws which I laid down for you, I shall tear the kingdom away from you and give it to one of your servants. For your father David’s sake, however, I shall not do this during your lifetime, but shall tear it out of your son’s hands. Even so, I shall not tear the whole kingdom from him. For the sake of my servant David, and for the sake of Jerusalem which I have chosen, I shall leave your son one tribe.’ [1 Kings 9:9–13, NJB]
Solomon’s own deeds merited the loss of the kingdom. The only reason he retained any of it at all was for David’s sake; the only reason it didn’t happen immediately (but rather not until after Solomon was dead) was for David’s sake.
In short: Solomon was blessed because of his father’s righteousness and in spite of his own sins. Now this is in a way trivially obvious. We see, for example, that a wicked man’s bad way of life has consequences for his family. And we see the same for the good man’s family too. But what we have here in 1 Kings (repeatedly) is a declaration that God would do these things for the righteous man’s sake. It’s not merely a case of practical cause and effect.
And the same sort of thing is seen in the New Testament: “the heartfelt prayer of someone upright works very powerfully” (James 5:16, NJB). Far from having no merit, and far from their merit being of no value to us, the merits of the saints are invaluable to us as we seek to be faithful to God.