php - include country code as array & store view as switch cases -


we assigning 5 store views 200 countries using below code.

now following below code in, at, ir, au country codes. usa, canada store views.

like need assign each country code 1 store view 200+ countries. there way can use array , use 5 switch cases & include many country codes in 1 switch case.

switch ($cncode) {                  case "in": {                     mage::app()->setcurrentstore('usa');                     break;                 }                   case "at": {                     mage::app()->setcurrentstore('usa');                     break;                  }                  case "ir": {                     mage::app()->setcurrentstore('usa');                     break;                 }                   case "au": {                     mage::app()->setcurrentstore('canada');                     break;                 }             } 

also fine other way less code.

you can use in_array:

if (in_array($encode, array('in', 'at', 'ir'))) {     mage::app()->setcurrentstore('usa'); } if (in_array($encode, array('au'))) {     mage::app()->setcurrentstore('canada'); } 

or combine cases:

switch ($encode) {     case 'in':     case 'at':     case 'ir':         mage::app()->setcurrentstore('usa');         break;     case 'au':         mage::app()->setcurrentstore('canada');         break; } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -