3

We have a single customer who ships to 100+ ship to addresses. It appears as if they are listed in random order when selecting a previous ship to address when entering orders on the backend of Magento. We enter the majority of our orders through the admin backend as we receive purchase orders via fax and/or email.

We run Magento 1.9.1.1 in production and 1.9.2 in a test environment (testing the latest patch).

I can't find much on this topic. Any pointers are greatly appreciated.

  • Also, I've noticed a huge performance lag when loading this customer in the backend. I had to increase available memory for PHP to 1024M just to get the page to display (show all addresses) in admin. Still need to be able to sort them. Anyone? – Christopher Clarke Aug 14 '15 at 22:25
1

There are no specific sort option for customer addresses collection by default, so items are sorted by entity_id field. As a simple solution here, you can add a default sort parameter to the customer addresses collection. For this you need to override the customer model (app/code/core/Mage/Customer/Model/Customer.php) and modify getAddressesCollection() method in the following way:

    public function getAddressesCollection()
    {
        if ($this->_addressesCollection === null) {
            $this->_addressesCollection = $this->getAddressCollection()
                ->setCustomerFilter($this)
                ->addAttributeToSelect('*')
                ->addAttributeToSort('city'); // This line has been added for sorting
            foreach ($this->_addressesCollection as $address) {
                $address->setCustomer($this);
            }
        }

        return $this->_addressesCollection;
    }

After this change the addresses list items will be sorted by 'city' parameter. You can use any field from customer address model here for sorting. Please note that this change will be applied globally to all addresses lists in the store. Also, try keep away from editing core files directly. If you need to make this change the easiest way is to copy all code from app/code/core/Mage/Customer/Model/Customer.php to app/code/local/Mage/Customer/Model/Customer.php (you need to create this file) and make all custom changes there. The preferred way is to create an extension for this purpose and make all changes there but this way requires a bit more time and Magento development knowledges.

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.