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/>";
}