If group_id is not
an attribute of Customer address type
.
So You cannot short address collection by group then that is not possible easily.
For this case,you need to add a left join with Customer/address
resource collection Class Mage_Customer_Model_Resource_Address_Collection
public function addGroupId(){
$this->joinAttribute('customer_group_id', 'customer/group_id', 'parent_id', 'entity_id', 'left');
};
Then at customer model (app/code/core/Mage/Customer/Model/Customer.php) and modify getAddressesCollection() method
public function getAddressesCollection()
{
if ($this->_addressesCollection === null) {
$this->_addressesCollection = $this->getAddressCollection()
->setCustomerFilter($this)
->addAttributeToSelect('*')
->addGroupId() // add this line at Collection for adding groupid customer address collection
->addAttributeToSort('customer_group_id'); // This line has been added for sorting
foreach ($this->_addressesCollection as $address) {
$address->setCustomer($this);
}
}
return $this->_addressesCollection;
}
If group_id is an attribute of entity_type_id=2
if If group_id is an attribute of entity_type_id=2 mean it is an attribute of customer_address then only need to modify at getAddressesCollection()
.
Just need to add ->addAttributeToSort('group_id') as per as your share lik How do I sort all of the multiple shipping addresses associated with a customer