I heard a fascinating sermon from a pastor/seminary professor on the final verses of Ecclesiastes. From his point of view, Solomon did not write these. It was a Godly narrative from later scribes/priests summing up the destructive human nature tendencies towards greed and excess, which summarized Solomon's reign in several ways.
Unlike his father, David, Solomon lived in excess and took materialism and sensuality to an extreme. King David repented of his failings; there is no indication his son ever did.
If nothing else, at least Solomon honestly documented the false doctrine that wealth and pleasure lead to happiness...
Yes that’s true of the introduction and conclusion for sure Solomon’s life and words are what the book is about it’s a narrative written by a narrator solomons wisdom and life experiences is the subject matter of the narration