2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

amazonMarketplaceWebServiceのcondition変換用関数

Posted at

amazon の MarketplaceWebServiceを使うときに混乱しやすい、conditionの値。
送信するときには英語名なのに、レポートで取得するときには数字で帰ってくるし、画面上には日本語で表示しないといけないし。
というわけで、変換するための関数です。
 ※※ソースの中に日本語入れると文字化けするのはなぜ???

//ex. $searchArray=array("jp"=>"中古品-可"),$keyName=number とすると
//日本語表記で「中古品-可」のステータスの番号を返す

function getConditionValue($searchArray,$keyName){

	$array=array(
		"11"=>array(
			"number"=>"11",
			"jp"=>"新品",
			"en"=>"New",
		),
		"1"=>array(
			"number"=>"1",
			"jp"=>"中古品-ほぼ新品",
			"en"=>"UsedLikeNew",
		),
		"2"=>array(
			"number"=>"2",
			"jp"=>"中古品-非常に良い",
			"en"=>"UsedVeryGood",
		),
		"1"=>array(
			"number"=>"3",
			"jp"=>"中古品-良い",
			"en"=>"UsedGood",
		),
		"4"=>array(
			"number"=>"4",
			"jp"=>"中古品-可",
			"en"=>"CollectibleAcceptable",
		),
	);
	foreach($array as $key=>$val){
		foreach($searchArray as $searchKey=>$searchVal){
			if($val[$searchKey]==$searchVal){
				return $val[$keyName];
			}
		}
	}
	return false;
}
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?