according to this article, its through kleptoplasty-- they eat algae and absorb the chloroplast of the algae into its own cells. the article claimed this is likely due to horizontal gene transfer from algae to sea slug of transcription factors necessary for the chloroplasts to function
please CW this