3

I'm trying to figure out the best way to interact with the Customer session using the service layer. I couldn't identify the proper repository to use. Any ideas?

Raphael at Digital Pianism
  • 70,385
  • 34
  • 188
  • 352
ryanF
  • 2,279
  • 1
  • 19
  • 31

1 Answers1

1

Unfortunately, at the moment, there's no implementation of the Customer Session via the Service Contracts.

I'm afraid you'll have to stick to the Magento\Customer\Model\Session class to achieve what you want.

Raphael at Digital Pianism
  • 70,385
  • 34
  • 188
  • 352
  • 1
    @Rapael at Digital Pianism...yea, I didn't see any implementation when I was digging around...was hoping someone else knew of something I didn't see :'( ... Thanks for confirming this...sigh, one day we'll have a completed service layer...one day! – ryanF Jun 13 '16 at 08:58
  • @ryanF well it may take some time but it's good to see people want to use it =) – Raphael at Digital Pianism Jun 13 '16 at 08:59
  • @Raphel at Digital Pianism Yea, the service layer is the way to go...it's also taught in the Fundamentals of Magento 2 Development...so it's funny that's it's taught as best practice, but isn't fully implemented. But I love the idea of creating one layer that can be used for modules and for API interaction...abstracts away details, so that theoretically models/collections could be changed at a later version and my code will still work (as long as interface signature remain backwards compatible ). – ryanF Jun 13 '16 at 09:02
  • @ryanF "taught as best practice, but isn't fully implemented" that's not only for the Service Contracts, see here: http://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly – Raphael at Digital Pianism Jun 13 '16 at 09:04
  • @Raphail at Digital Pianism, yea I just read that comment a few minutes ago as well...yea, there's still a lot of refactoring to go in the codebase. BUT, the saving grace is the release schedule...if Magento is able to stay on track, and devotes enough time to each sprint to address these issues (versus just making new features), then we should see some slow and steady progress. That's my hopes anyway...either that or it's PR time lol – ryanF Jun 13 '16 at 09:08