<?php require_once __DIR__ . '/../RemoteService.php'; try { // Get a sales order information by Magento increment ID $service = new RemoteService(); $result = $service->catalogProductInfo(array('productId' => $argv[1], 'storeId' => $argv[2])); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); // Get a sales order list by the applied filters $result = $service->catalogCategoryLevel(array()); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { // Get a sales order information by Magento increment ID $service = new RemoteService(); $result = $service->salesOrderInfo(array('orderIncrementId' => $argv[1])); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); $filters = array('filter' => array(), 'complex_filter' => array(array('key' => 'created_at', 'value' => array('key' => 'gteq', 'value' => date('Y-m-d', strtotime('-1 month')))))); // Get a sales order list by the applied filters $result = $service->customerCustomerList(array('filters' => $filters)); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; if (!isset($argv[1])) { die('Require products IDs as comma separated list'); } $productIds = explode(',', $argv[1]); try { $service = new RemoteService(); $baseData = ['manage_stock' => 1, 'use_config_manage_stock' => 0, 'min_qty' => 1, 'use_config_min_qty' => 0, 'min_sale_qty' => 1, 'use_config_min_sale_qty' => 0, 'max_sale_qty' => 0, 'use_config_max_sale_qty' => 0, 'is_qty_decimal' => 0, 'backorders' => 0, 'use_config_backorders' => 0, 'notify_stock_qty' => 0, 'use_config_notify_stock_qty' => 0]; foreach ($productIds as $productId) { $result = $service->catalogInventoryStockItemList(['productIds' => [$productId]]); $currentQty = $result->result->complexObjectArray->qty; $data = ['qty' => mt_rand(0, 1) == 1 ? mt_rand(0, 1000) : $currentQty]; $data['is_in_stock'] = (int) ($data['qty'] == 0); $result = $service->catalogProductInfo(['productId' => $productId]); $sku = $result->result->sku; $service->salesOrderStockQuantityList(['orderStatuses' => ['pending', 'processing', 'to_collect'], 'skus' => [$sku]]); $result = $service->catalogInventoryStockItemUpdate(['productId' => $productId, 'data' => array_merge($baseData, $data)]); } } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; if (!isset($argv[1])) { die('Please provide order increment ID' . PHP_EOL); } $orderIncrementId = $argv[1]; try { $service = new RemoteService(); $order = $service->salesOrderInfo(array('orderIncrementId' => $orderIncrementId)); $invoice = $service->salesOrderInvoiceList(['filters' => ['filter' => [['key' => 'order_id', 'value' => $order->result->order_id]]]]); $invoiceIncrementId = $invoice->result->complexObjectArray->increment_id; $items = array(); foreach ($order->result->items->complexObjectArray as $item) { echo "[{$item->sku}] {$item->name} £{$item->row_invoiced} - "; $qty = (int) $service->ask("Qty to Refund [{$item->qty_invoiced}]", 'text', $item->qty_invoiced); if ($qty > $item->qty_invoiced || $qty < 0) { die('Invalid Quantity' . PHP_EOL); } if ($qty >= 0) { $cmItem = new stdClass(); $cmItem->order_item_id = $item->item_id; $cmItem->qty = $qty; $items[] = $cmItem; $rrItem = new stdClass(); $rrItem->order_item_id = $item->item_id; $rrItem->return_code = 1; $rrs[] = $rrItem; } } if (empty($items)) {
<?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";
<?php require_once __DIR__ . '/../RemoteService.php'; if (!isset($argv[1])) { die('Please provide order increment ID' . PHP_EOL); } $orderIncrementId = $argv[1]; try { $service = new RemoteService(); $order = $service->salesOrderInfo(array('orderIncrementId' => $orderIncrementId)); $items = array(); foreach ($order->result->items->complexObjectArray as $item) { echo "[{$item->sku}] {$item->name} £{$item->row_invoiced} - "; $qty = (int) $service->ask("Qty to Ship [{$item->qty_invoiced}]", 'text', $item->qty_invoiced); if ($qty > $item->qty_invoiced || $qty < 0) { die('Invalid Quantity' . PHP_EOL); } if ($qty > 0) { $shipItem = new stdClass(); $shipItem->order_item_id = $item->item_id; $shipItem->qty = $qty; $items[] = $shipItem; } } if (empty($items)) { die('No items to ship' . PHP_EOL); } $result = $service->salesOrderShipmentCreate(array('orderIncrementId' => $orderIncrementId, 'itemsQty' => $items, 'comment' => 'Test Shipment', 'email' => 1, 'includeComment' => 1)); print_r($result); echo PHP_EOL; } catch (SoapFault $e) {
<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); $params = ['orderStatuses' => ['processing']]; // Get a sales order list by the applied filters $result = $service->salesOrderStockQuantityList($params); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { // Get a sales order information by Magento increment ID $file = new stdClass(); $file->content = base64_encode(file_get_contents($argv[2])); $file->mime = 'image/jpeg'; $file->name = 'Kitten'; $media = new stdClass(); $media->file = $file; $media->label = 'Kitten'; $media->position = 1; $media->types = array('small_image', 'image', 'thumbnail'); $media->storeView = 'default'; $service = new RemoteService(); $result = $service->catalogProductAttributeMediaCreate(array('product' => $argv[1], 'data' => $media)); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); // Get a sales order list by the applied filters $result = $service->catalogCategoryTree(array()); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { // List customer addresses by customer ID $service = new RemoteService(); $result = $service->customerAddressInfo(array('addressId' => $argv[1])); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once 'RemoteService.php'; try { $service = new RemoteService(); $service->execute(); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { // Get customer Info by ID $service = new RemoteService(); $result = $service->customerCustomerInfo(array('customerId' => $argv[1])); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { // List customer addresses by customer ID $service = new RemoteService(); $result = $service->customerAddressList(array('customerId' => $argv[1])); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); $result = $service->catalogProductAttributeOptions(array('attributeId' => 'color', 'storeView' => 'default')); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?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 { $questions = array(array('param' => 'email', 'question' => 'Email', 'type' => 'text'), array('param' => 'firstname', 'question' => 'First Name', 'type' => 'text'), array('param' => 'lastname', 'question' => 'Last Name', 'type' => 'text'), array('param' => 'password', 'question' => 'Password', 'type' => 'password'), array('param' => 'website_id', 'question' => 'Website ID', 'type' => 'text')); $service = new RemoteService(); $data = array(); foreach ($questions as $question) { $data[$question['param']] = $service->ask($question['question'], $question['type']); } $result = $service->customerCustomerCreate(array('customerData' => $data)); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; if (!isset($argv[1])) { die('Require products IDs as comma separated list'); } $productIds = explode(',', $argv[1]); try { $service = new RemoteService(); $result = $service->catalogInventoryStockItemList(['productIds' => $productIds]); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); if (!isset($argv[1])) { die("Please provide an Order ID\n"); } $orderId = $argv[1]; $filters = array('filter' => array(array('key' => 'order_id', 'value' => $orderId))); // Get a sales order list by the applied filters $result = $service->salesOrderInvoiceList(array('filters' => $filters)); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }
<?php require_once __DIR__ . '/../RemoteService.php'; try { $service = new RemoteService(); $result = $service->catalogProductAttributeAddOption(array('attribute' => 'color', 'data' => array('label' => array(array('store_id' => array(0), 'value' => 'Blue')), 'order' => 0, 'is_default' => 0))); print_r($result); } catch (SoapFault $e) { echo "Exception '" . get_class($e) . "':\n"; print_r($e); }