2014-03-13 62 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; 
} 
相關問題