2

I've created a new installation with Magento 1.9.4.1 for a client of mine. But here is the problem, all the country dropdown options are not sorted ASC. For example, if I choose a country on the checkout page this will show all the countries but not in correct order.

eg: Taiwan Belgium United States Angora

I hope someone is able to help me with this question, thank you in advance :).

Best regards, Myron

1

Create your own module (if it's not exist yet). Rewrite Mage_Directory_Model_Resource_Country_Collection class:

<config>
    <modules>
        <Your_Module>
            <version>0.0.0.1</version>
        </Your_Module>
    </modules>
    <global>
        <models>
            <directory_resource>
                <rewrite>
                    <country_collection>Your_Module_Model_Resource_Directory_Country_Collection</country_collection>
                </rewrite>
            </directory_resource>
        </models>
    </global>
</config>

Create the following file in your Magento root dir:

/app/code/local/Your/Module/Model/Resource/Directory/Country/Collection.php

with the following content:

<?php

class Your_Module_Model_Resource_Directory_Country_Collection
    extends Mage_Directory_Model_Resource_Country_Collection
{

    protected function _initSelect()
    {
        parent::_initSelect();

        $this
            ->addOrder('country_id', 'asc');

        return $this;
    }
}

Reference: https://stackoverflow.com/questions/4473880/magento-country-reorder

|improve this answer|||||
  • Hi Shoaib, Thanks for your answer, i did this and found out that the _initSelect() didn't work anymore so i combined 2 answers from the referenced post you've added to make it work! Thanks!!! – Myron May 22 '19 at 8:33
  • That's great. welcome.. +1 for appreciation :) – Shoaib Munir May 22 '19 at 8:34
1

I will try this and update with the outcome. Alternatively, Shoaib apna koi contact ka tareeka bata do. I have a project that I would like to discuss.

|improve this answer|||||

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.