我是新的magento,我想覆盖位于 /app/code/core/Mage/Directory/Helper/Data.php的"Data.php"文件
我想从DropDownList中删除不需要的状态。
下面是我在Data.php文件中的函数
受保护的函数_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) - >负载(); $ regions = array( 'config'=>array( 'show_all_regions'=>$ this->getShowNonRequiredState(), 'regions_required'=>$ this->getCountrieswithStatesRequired() ) ); foreach($ collection as $ region){ if(!$ region->getRegionId()){ 继续; } // EOF自定义逻辑 $ regions [$ region->getCountryId()] [$ region->getRegionId()] = array( 'code'=>$ region->getCode(), 'name'=>$ this - >__($ region->getName()) ); } 返回$ regions; }
在上面的函数中,我想添加用于从下拉列表中删除不需要的状态的代码.我已经为此添加了代码,但是当我添加上述函数时,我没有任何效果。
受保护的函数_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) - >负载(); $ regions = array( 'config'=>array( 'show_all_regions'=>$ this->getShowNonRequiredState(), 'regions_required'=>$ this->getCountrieswithStatesRequired() ) ); $ excludeRegions = array('AE','AA'); foreach($ collection as $ region){ if(!$ region->getRegionId()){ 继续; } // BOF自定义逻辑 *** $ regionCode = $ region->getCode(); 从(阵列( '区域'=>$此>_选择 - >- - $这>_ regionTable), array('region_id'=>'region_id','country_id'=>'country_id','code'=>'code','default_name'=>'default_name') ) - >where('code NOT IN(?)',$ exclude_regions); *** // EOF自定义逻辑 $ regions [$ region->getCountryId()] [$ region->getRegionId()] = array( 'code'=>$ region->getCode(), 'name'=>$ this - >__($ region->getName()) ); } 返回$ regions; }
即使是整个Data.php文件以及上面的更改我都保存在本地目录中但它不起作用。
最新回答
- 2019-12-51 #
相关问题
- magento 1.9:自定义表左连接目录/产品magento1.9magentodatabasemagentocollectionmagentocatalogmagentoeav2019-12-05 21:44
- php:magento 1x当订单全额退款完成后需要生成自定义邮件magento1.9magentophp2019-12-05 21:41
- php:Magento将日期显示为多个值magento1.9magentophpmagentodate2019-12-05 21:41
- php:如何在表格magento 19中添加保存按钮magento1.9magentophpmagentoadminhtml2019-12-05 21:40
- magento 1.9:如何在我的自定义模块控制器中使用核心模块(observerphp)的动作方法。magento1.9magentophp2019-12-05 21:39
我不鼓励你使用这种覆盖方式,比如创建
app/code/local/Mage/Directory/Helper/Data.php
,这只是意大利面条代码的好方法..创建一个模块
Vids_Directory
在游泳池local
类似app/code/local/Vids/Directory
创建
app/etc/modules/Vids_Directory.xml
和这段代码:创建
app/code/local/Vids/Directory/etc/config.xml
并添加以下代码:最后,你可以创建
app/code/local/Vids/Helper/Data.php
并添加:Note :你的代码
$this->_select->from...
什么都没有,小心(或者你可能错过了添加完整的代码?)。希望它能帮到你:)。