Skip to content

Magento : Get All Customer Wishlist Items

here you go

$mod = Mage::getModel('wishlist/wishlist')->getCollection();
$data_wishlist = array();
foreach($mod as $data)
{
$item_array = array();
$load = Mage::getModel('wishlist/wishlist')->load($data->getId())->getItemCollection();
$customer = Mage::getModel('customer/customer')->load($data->getCustomerId());
$count = 0;
foreach($load as $item)
{
$product = $item->getProduct();
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
$item_array[] = array(
'product_id' => $product->getId(),
'product_name' => $product->getName(),
'qty_ordered' => $item->getQty(),
'stock_available' => $stockItem->getIsInStock()
);
$count++;
}
if($count){
$data_wishlist[] = array(
'customer_id' => $data->getCustomerId(),
'customer_email' => $customer->getEmail(),
'customer_name' => $customer->getFirstname() .' '. $customer->getLastname(),
'last_update' => $data->getUpdatedAt(),
'item_list' => $item_array
);
};
}
echo '<pre>';
print_r($data_wishlist);

 

the results will be like this

 

Array
(
    [0] => Array
        (
            [customer_id] => 136
            [customer_email] => [email protected]
            [customer_name] => Jane Doe
            [last_update] => 2013-05-29 08:00:19
            [item_list] => Array
                (
                    [0] => Array
                        (
                            [product_id] => 549
                            [product_name] => Blue Horizons Bracelets
                            [qty_ordered] => 1.0000
                            [stock_available] => 0
                        )

                )

        )

    [1] => Array
        (
            [customer_id] => 135
            [customer_email] => [email protected]
            [customer_name] => John Doe
            [last_update] => 2013-06-21 00:31:23
            [item_list] => Array
                (
                    [0] => Array
                        (
                            [product_id] => 409
                            [product_name] => Chelsea Tee
                            [qty_ordered] => 1.0000
                            [stock_available] => 1
                        )

                )

        )

 

 

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *