0

Thank you for making your attention to my question.

I'd like to show Region List ordered by region_id on the DB with RegionUpdater. Currently its ordered by Region's name alphabet. I tried to modified the following files but haven't succeed to change it.

Modified file: "./app/code/core/Mage/Directory/Helper/Data.php" tried to add "->setOrder('region_id', 'ASC')"

Our environment is Magento 1.9.3.1.

If you have any idea to solve this, let me have your help.enter image description here

Regards, 7steps

  • Have you tried refreshing the Config cache? – kiatng Aug 15 '18 at 3:49
0

First, Make sure to never modify core files. Always try to overwrite the classes in your own module. Click here for help overwriting a helper.

In your overwritten class you should override this method with the following code:

public function getRegionCollection()
{
    if (!$this->_regionCollection) {
        $this->_regionCollection = Mage::getModel('directory/region')->getResourceCollection()
            ->addCountryFilter($this->getAddress()->getCountryId())
            ->setOrder('region_id', Varien_Data_Collection::SORT_ORDER_ASC)
            ->load();
    }
    return $this->_regionCollection;
}

Regions in the table directory_country_region are by default sorted by alphabetically, so doing this would make no effect unless you changed the region ids yourself. Which I not recommend you do.

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.