Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. protected $customerSession;
  2. protected $wishlist;
  3.  
  4. public function __construct(
  5. ...
  6. MagentoCustomerModelSession $customerSession,
  7. MagentoWishlistModelWishlist $wishlist,
  8. ...
  9. ) {
  10. ...
  11. $this->customerSession = $customerSession;
  12. $this->wishlist = $wishlist;
  13. ...
  14. }
  15.  
  16. public function yourFunction(){
  17. $customer_id = $this->customerSession->getCustomer()->getId();
  18. $wishlist_collection = $this->wishlist->loadByCustomerId($customer_id, true)->getItemCollection();
  19. $product_ids = [];
  20. foreach ($wishlist_collection as $item) {
  21. $product_ids[] = $item->getProduct()->getId();
  22. }
  23. return $product_ids;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement