Question

Hi i am using below code for wishlist but i not getting below result.

$customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
$wishList = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer);

Mage_Wishlist_Model_Wishlist Object
(
    [_eventPrefix:protected] => wishlist
    [_itemCollection:protected] => 
    [_store:protected] => 
    [_storeIds:protected] => 
    [_cacheTag:protected] => wishlist
    [_eventObject:protected] => object
    [_resourceName:protected] => wishlist/wishlist
    [_resource:protected] => 
    [_resourceCollectionName:protected] => wishlist/wishlist_collection
    [_dataSaveAllowed:protected] => 1
    [_isObjectNew:protected] => 
    [_data:protected] => Array
        (
        )

    [_hasDataChanges:protected] => 
    [_origData:protected] => 
    [_idFieldName:protected] => wishlist_id
    [_isDeleted:protected] => 
    [_oldFieldsMap:protected] => Array
        (
        )

    [_syncFieldsMap:protected] => Array
        (
        )

)
Was it helpful?

Solution

Because in this case you get as a result customer collection and not customer model.

$customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');

loadByCustomer function takes the argument which type is Mage_Customer_Model_Customer or customer's id.

You can use:

$customer = Mage::getModel('customer/customer')->load($id)

Or get first element of collection. Or use foreach loop to iterate through collection.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top