function downloadFile($cacheFile) { file_put_contents($cacheFile, ''); $options = array('exceptions' => true, 'trace' => true, 'encoding' => 'utf-8'); $clientScript = new SoapClient(getWSDL(), $options); $session = $clientScript->login('B2BUser', 'B2BUser'); $array = array(); // $array[] = array('key'=>'created_at','value'=>array('key' =>'from','value' => trim('0001-01-01'))); $array[] = array('key' => 'created_at', 'value' => array('key' => 'from', 'value' => trim('2015-08-03'))); $params = array('complex_filter' => $array); $products = $clientScript->catalogProductList($session, $params); $attributeSets = array(); $attributeSetsMage = $clientScript->catalogProductAttributeSetList($session); foreach ($attributeSetsMage as $attributeSetMage) { $attributeSets[$attributeSetMage->set_id] = trim($attributeSetMage->name); } echo "Attribute Sets:\n" . print_r($attributeSets, true); echo "\n"; $manufacturers = array(); $manufacturersMage = $clientScript->catalogProductAttributeOptions($session, 'manufacturer'); foreach ($manufacturersMage as $manufacturerMage) { if (trim($manufacturerMage->value) !== '') { $manufacturers[$manufacturerMage->value] = trim($manufacturerMage->label); } } echo "Manufacturers:\n" . print_r($manufacturers, true); echo "\n"; echo "Got " . count($products) . " products\n"; foreach ($products as $index => $product) { try { echo "No.: " . $index . ", SKU:" . $product->sku . "\n"; $pro = $clientScript->catalogProductInfo($session, trim($product->sku), null, getInfoAttributes()); $proArray = getProductArray($clientScript, $session, $product, $pro, $attributeSets, $manufacturers); echo "\t JSON: " . json_encode($proArray) . "\n"; if (count($proArray) > 0) { file_put_contents($cacheFile, json_encode($proArray) . "\n", FILE_APPEND); } } catch (SoapFault $e) { var_dump($e); } } echo "File :" . $cacheFile . ' downloaded.'; }