1

I tried to do what all the person have done without problems

$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect(array('email'), 'inner');
Mage::getSingleton('core/resource_iterator')->walk($customers->getSelect(), array(array($this, 'customerCallback')));


function customerCallback($args)
{
    $customer = Mage::getModel('customer/customer'); // get customer model
    $customer->setData($args['row']); // map data to customer model
    echo $customer->getFirstname(); // set value of firstname attribute
}

But, for me, it doesn't works an i don't know why. The error is:

PHP Fatal error:  Uncaught exception 'Exception' with message 'Warning: call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
3

Just put this code inside a class. Example:

$test = new MyClass;
$test->run();

class MyClass
{
    public function run()
    {
        $customers = Mage::getModel('customer/customer')->getCollection()
            ->addAttributeToSelect(array('email'), 'inner');

        Mage::getSingleton('core/resource_iterator')->walk(
            $customers->getSelect(),
            array(array($this, 'customerCallback'))
        );
    }

    public function customerCallback($args)
    {
        $customer = Mage::getModel('customer/customer'); // get customer model
        $customer->setData($args['row']); // map data to customer model
        echo $customer->getFirstname(); // set value of firstname attribute
    }
}

Edit:

Please read this: http://php.net/manual/en/function.call-user-func.php

Without using a class the code has to look like this:

Mage::getSingleton('core/resource_iterator')->walk(
    $customers->getSelect(),
    array('customerCallback') // changed here
);
  • works, but why? – characterError Jun 12 '17 at 11:33
  • Sorry, i can't upvote, i haven't enought reputation, but i appreciate your help so much – characterError Jun 13 '17 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.