I am new magento and I want to override my "Data.php" file which is located at /app/code/core/Mage/Directory/Helper/Data.php
I want to remove the unwanted states from DropDownList.
Below is my Function in Data.php file
protected function _getRegions($storeId) { $countryIds = array(); $countryCollection = $this->getCountryCollection()->loadByStore($storeId); foreach ($countryCollection as $country) { $countryIds[] = $country->getCountryId(); } /** @var $regionModel Mage_Directory_Model_Region */ $regionModel = $this->_factory->getModel('directory/region'); /** @var $collection Mage_Directory_Model_Resource_Region_Collection */ $collection = $regionModel->getResourceCollection() ->addCountryFilter($countryIds) ->load(); $regions = array( 'config' => array( 'show_all_regions' => $this->getShowNonRequiredState(), 'regions_required' => $this->getCountriesWithStatesRequired() ) ); foreach ($collection as $region) { if (!$region->getRegionId()) { continue; } //EOF Custom Logic Here $regions[$region->getCountryId()][$region->getRegionId()] = array( 'code' => $region->getCode(), 'name' => $this->__($region->getName()) ); } return $regions; }
In the above function I want to add code for removing the unwanted states from dropdown. I have added the code for this but when I am adding in the above function I am not getting any effect.
protected function _getRegions($storeId) { $countryIds = array(); $countryCollection = $this->getCountryCollection()->loadByStore($storeId); foreach ($countryCollection as $country) { $countryIds[] = $country->getCountryId(); } /** @var $regionModel Mage_Directory_Model_Region */ $regionModel = $this->_factory->getModel('directory/region'); /** @var $collection Mage_Directory_Model_Resource_Region_Collection */ $collection = $regionModel->getResourceCollection() ->addCountryFilter($countryIds) ->load(); $regions = array( 'config' => array( 'show_all_regions' => $this->getShowNonRequiredState(), 'regions_required' => $this->getCountriesWithStatesRequired() ) ); $excludeRegions = array('AE','AA'); foreach ($collection as $region) { if (!$region->getRegionId()) { continue; } //BOF Custom Logic Here ***$regionCode = $region->getCode(); $this->_select->from(array('region'=>$this->_regionTable), array('region_id'=>'region_id', 'country_id'=>'country_id', 'code'=>'code', 'default_name'=>'default_name') )->where('code NOT IN (?)', $exclude_regions);*** //EOF Custom Logic Here $regions[$region->getCountryId()][$region->getRegionId()] = array( 'code' => $region->getCode(), 'name' => $this->__($region->getName()) ); } return $regions; }
Even the whole Data.php file along with the above change i kept in local directory but it didn't work.