<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); if (is_null($service->arg(1))) { die("Please supply CSV file with products to import"); } $file = $service->arg(1); $fh = fopen($file, 'r'); $headers = fgetcsv($fh); $tree = $service->catalogCategoryTree(array()); $categories = flattenTree($tree->children); while (false !== ($row = fgetcsv($fh))) { $data = array_combine($headers, $row); $sku = $data['sku']; echo "SKU '{$sku}': "; unset($data['sku']); $data = array_merge(array('websites' => array('base'), 'category_ids' => '', 'visibility' => 4, 'status' => 1, 'weight' => 1, 'tax_class_id' => 2), $data); $data['websites'] = explode(',', $data['websites']); $data['category_ids'] = $categories[$data['category']]; $products = $service->catalogProductList(array('filters' => array('filter' => array(array('key' => 'sku', 'value' => $sku))))); if (!empty($products)) { $productId = $products[0]->product_id; $service->catalogProductUpdate(array('product_id' => $productId, 'data' => $data)); echo "Updated Product ID: " . $productId . "\n"; } else { $productId = $service->catalogProductCreate(array('type' => 'simple', 'set' => 4, 'sku' => $sku, 'productData' => $data)); echo "Created Product ID: " . $productId . "\n"; } }
<?php require_once __DIR__ . '/../RemoteService.php'; try { // Get a sales order information by Magento increment ID $service = new RemoteService(); $orderId = $service->arg(1); $status = $service->arg(2); $comment = $service->arg(3); if (is_null($orderId)) { die("Please provide an order increment ID to set the status for\n"); } if (is_null($status)) { die("Please provide a status to set\n"); } if (is_null($comment)) { $comment = "Order status set to '{$status}' using API"; } $result = $service->salesOrderInfo(array('orderIncrementId' => $orderId)); if ($result->result->status == $status) { die("Order {$orderId} is already in state '{$status}'\n"); } else { $result = $service->salesOrderAddComment(array('orderIncrementId' => $orderId, 'status' => $status, 'comment' => $comment)); if ($result) { echo "Updated {$orderId} to status '{$status}'\n"; } else { echo "Order {$orderId} failed to update status.\n"; } } } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n";