magento から製品リストを取得する際に問題が発生しています。ajax を使用して aa 値を送信し、その値を magento soap 呼び出しのフィルター値として使用していますが、機能していません。製品の詳細を取得できませんでした。
しかし、同じ webservice.php ファイルで値を変数にハードコーディングすると、動作します..
私がしてしまった過ちは何ですか...
ここに私の ajax.php & webservice.php ファイルがあります
ajax.php
// ajax script
<script>
//item_code is text box , user enter some value to it.
$('#item_code').live("keyup",function(){
item_code = $('#item_code').val();
$.ajax({
url:"webservice.php",
type:"POST",
dataType: "json",
data : '&item_code= ' + item_code,
cache:false,
success:
function (data) {
if (data.successfully_inserted == "passed")
{
alert('ok');
}
else
{
alert('error');
}
}
});
});
</script>
webservice.php
<?php
//$item_code = 'abc' ; // This works , I can get the correct result.
$item_code = $_POST['item_code']; // when I assign $item_code to post data value it does not work. I echo it, data was posted correctly.
$client = new SoapClient('http://myhost/index.php/api/soap/?wsdl');
$session = $client->login('test', 'test1234');
$filters = array(
'item_code' => array('where'=>$item_code)
);
/* $filters = array(
'item_code' => array('like'=>''.$item_code.'%')
); */
$products = $client->call($session, 'catalog_product.list', array($filters) );
print_r($products);
echo '{"successfully_inserted": "passed"}';