My first post here so please be nice....

I have some php files that are suppose to work with Magento API. The creator says they work however I don't get the results so they appear not to work.

Here's some code; This is the part that is giving me trouble and since I do not know how this code works, I'm kinda at a stand still.

The originators XML feed appears like this:

<?xml version="1.0" ?>
<products>
<product sku="15569" mfg_part_number="405970-1" upc="082324027055">
<inventory quantity="13"/>
<price your_price="143.18" list="159.99"/>
<description short="A product description"/>
</product>

My XML feed appears like this:

<product cwr_sku="10001" mfg_part_number="1930.3" upc="791659193037">
<inventory quantity="4"/>
</product>

Ok, now here is the code that supposedly make this all work?

Code:
//include the Magento API file - replace with your server path to the file
require_once('/some/path/to/public_html/app/Mage.php');
 
// ***** Configuration ******
$myDomain = 'http://www.yourdomain.com';
$myAPILogin = 'username';
$myAPIKey = 'password';
 
//calculate the price markup - useful if you have a standard markup you apply
$myMarkUp = .30;
$defaultMarkup = .30;
 
// get my saved file name
$myFilename = 'product_feed.xml';
 
//load up local xml file for processing
$feed_xml = simplexml_load_file($myFilename);
 
// Begin SOAP Requests
$client = new SoapClient($myDomain.'/api/?wsdl');
$session = $client->login($myAPILogin, $myAPIKey);
 
$updatedProducts = "";
 
//some counters - counting loops this way lets me see and set where the count increments
$x = 0;
 
//some filter date to pass to the API - add more to filter your results further - see Magento API docs
$filterData = array('type'=>'simple');
 
//get all my database products into an array
$products = $client->call($session, 'catalog_product.list', array($filterData));
 
 
//loop through my product array
foreach ($products as $product) {
 
echo "Starting product loop...<br/><br/>";
 
 
//get my database product sku - for cleaner reference in the code
$mysku = $product['sku']
 
//search directly in the product sku attribute in the xml for my sku
$res = $feed_xml->xpath("//product[@sku='$mysku']");
 
 
// if we find one, lets process it
if(!empty($res)) {
 
	//matched - make updates
	echo "Matched: ".$mysku;
 
	//price updates
	if ($res[0]->price['list'] != '') {
		$newprice = $res[0]->price['your_price'] + (($res[0]->price['list'] - $res[0]->price['your_price'])*$myMarkUp);
	} else {
		$newprice = $res[0]->price['your_price'] + ($res[0]->price['your_price']*$defaultMarkup);
	}
 
	//build my array to pass to the magento API
	$fieldPriceData = array('cost'=>$res[0]->price['your_price']*1, 'price'=>$newprice, 'upc'=>$res[0]->product['upc']);
	//update magento with price data
	$client->call($session, 'catalog_product.update', array($product['sku'], $fieldPriceData));
 
	//qty and stock updates
	if (($res[0]->inventory['quantity']*1) != 0) {
		$fieldQtyData = array('qty'=>$res[0]->inventory['quantity']*1, 'is_in_stock'=>1);
		echo "In Stock<br/>";
	} else {
		$fieldQtyData = array('qty'=>$res[0]->inventory['quantity']*1, 'is_in_stock'=>0);
		echo "Out of Stock<br/>";
	}
 
	//update magento with quantity and stock data
	$client->call($session, 'product_stock.update', array($product['sku'], $fieldQtyData));
 
	//record the updated product for emailing later
	$updatedProducts .= "SKU: ".$mysku." - ".$res[0]->description['short']."\nPrice: ".$newprice."\nCost: ".$res[0]->price['your_price']."\nQty: ".$res[0]->inventory['quantity']."\n\n";
 
	//increment my counter
	$x = $x + 1; 
 
} else {
 
echo "no match<br/><br/>";
 
}
 
// send mail to me
$to = "you@yourdomain.com";
$subject = "Feed Processed";
$body = "Hi,\n\nThe latest data for ".$myDomain." has been processed on ".date('l jS \of F Y h:i:s A')."\n\n";
$body .= "Products Updated: ".$x."\n\n".$updatedProducts;
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
	 } else {
 echo("<p>Message delivery failed...</p>");
}
I've modified my code trying to remove everything but the code pertaining to the sku and the quantity. I get it to run but it does not change the qty?

If possible, could someone please explain how this works.

I believe the problem lies within this part?

Code:
//qty and stock updates
	if (($res[0]->inventory['quantity']*1) != 0) {
		$fieldQtyData = array('qty'=>$res[0]->inventory['quantity']*1, 'is_in_stock'=>1);
		echo "In Stock<br/>";
	} else {
		$fieldQtyData = array('qty'=>$res[0]->inventory['quantity']*1, 'is_in_stock'=>0);
		echo "Out of Stock<br/>";
What is suppose to happen is, if the xml file shows a quantity of greater than 1, it should update the quantity, and also change the product to show "is_in_stock"?
I've ran this with just one product is the xml feed but it does not change it.

We really appreciate any help here as we have been trying to find out how to make updating our store stock easier. We have over 12,000 products.