2 added 276 characters in body
source | link

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
);

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
    }
}

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
);
1
source | link

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
    }
}