I'm having an issue with retrieving the product list from magento . I'm sending a a value using ajax , then I use that value as a filter value for magento soap call, but it 's not working, I couldn't get the product details .
but when I hard coded the value to variable in the same webservice.php file it works ..
What's the fault I have done ...
here is my ajax.php & webservice.php files
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"}';