SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top