Good Morning,

I'm receiving a SOAP error when I try to pull all of my products (20k) into an array. So, I want to limit the script and only grab 1/3 of the database. How would I do that?

Here is the code that is erroring:

$products = $client->call($session, 'catalog_product.list', array($filterData));

Here is a larger sample of the code:

//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 (We need to sort through the records.  We are loading too many and its erroring)
//$products = $client->call($session, 'catalog_product.list', array($filterData));
$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("//Available[@Part='$mysku']");
 
 
// if we find one, lets process it
if(!empty($res)) {
 
	//matched - make updates
	echo "Matched: ".$mysku;
if (($res[0]->Available['Qty']*1) != 0) {
		$fieldQtyData = array('qty'=>$res[0]->Available['Qty']*1, 'is_in_stock'=>1);
		echo "In Stock<br/>";
	} else {
		$fieldQtyData = array('qty'=>$res[0]->Available['Qty']*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." - "."Qty: ".$res[0]->inventory['quantity']."\n\n";
 
	//increment my counter
	$x = $x + 1; 
 
} else {
 
echo "no match<br/><br/>";
 
}

do you have access to the soap code itself?
you need to change your api code if possible.
maybe make three calls.
instead of

catalog_product.list
catalog_a.list
catalog_b.list
catalog_c.list
//where each of the lists returns only a third of your data.

if you don't have access to the api, I'm at a loss for the moment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.