I would like to be able to load a customer's wishlist and return the product id's of the products within the list
I am using:
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();
The problem is that the arrays in the Item Collection are protected and I can't find any methods to extract the data.
Is there another way to do this?
The customer id is required to fetch the customer placed Order collection in Magento 2. Get Customer Order collection, We have to create a factory object of Magento\Sales\Model\ResourceModel\Order\Collection class. Instantiate the Factory object to the __consturct() method and apply condition with customer id.
From the Admin panel, select System > Configuration. In the Configuration panel on the left, under Customers, select the Wishlist tab. Click to expand the General Options section and do one of the following: Set Enabled to Yes to display the Add to Wishlist link on category pages and product pages.
You can get wishlist collection of a customer by customer id. You can show detail of Customer Wishlist item in a store. Get Wishlist collection by calling Magento\Wishlist\Model\Wishlist Model file.
You're very close to your target.
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();
if (count($wishListItemCollection)) {
$arrProductIds = array();
foreach ($wishListItemCollection as $item) {
/* @var $product Mage_Catalog_Model_Product */
$product = $item->getProduct();
$arrProductIds[] = $product->getId();
}
}
The array variable $arrProductIds
will now contain the list of all Product IDs that have been wishlisted by that specific Customer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With