2014-03-13 38 views
0

我有一个多商店网站,我需要更改基于商店的国家/地区的顺序。就像我在以色列的商店一样,以色列必须处于顶端,美国商店必须处于顶端。重新安排使用国家地区

是否有任何可能的方式在magento中这样做?我发现了一个answer on SO,但国家名单没有变化。有没有可能以这种方式对国家进行重新排序?

回答

0

我也在寻找相同的和answerAlex B不起作用在我的情况。此外代码

$this->addOrder('country_id="US"','desc') 
    ->addOrder('country_id', 'asc'); 

在国家列表中没有任何更改。所以,而不是重写_initSelect()我选择toOptionArray()覆盖。这里是我的代码

public function toOptionArray($emptyLabel = '') { 
    $options = parent::toOptionArray($emptyLabel); 
    foreach ($options as $key => $option) { 
     if ($option['value'] == 'IN') { //check current country code 
      unset($options[$key]); 
      $options = addCountryToIndex($options, $option, 1); 
     } 
    } 
    return $options; 
} 

protected function addCountryToIndex($countries, $country, $index){ 
    $options = array_slice($countries, 0, $index, true) + 
     array($index => $country) + 
     array_slice($countries, $index, count($countries) - 1, true); 
    return $options; 
} 
相关问题