/** * Lists up to 5 items with eBay * * @param array $products An array of products to list * @param ISC_ADMIN_EBAY_TEMPLATE $template The template to list the product with * @return array Array of ISC_ADMIN_EBAY_LIST_ITEM_RESULT objects for each item listed */ public static function listItems($products, $template) { ISC_ADMIN_EBAY_OPERATIONS::setSiteId($template->getSiteId()); $results = array(); $regularProducts = array(); // any products with a variation should be listed separately with a FixedPriceItem request foreach ($products as $productId => $product) { if ($product['prodvariationid']) { try { $xml = ISC_ADMIN_EBAY_OPERATIONS::addFixedPriceItem($product, $template); } catch (ISC_EBAY_API_REQUEST_EXCEPTION $ex) { $xml = $ex->getResponseXML(); } $results[] = new ISC_ADMIN_EBAY_LIST_ITEM_RESULT($product, $xml); } else { $regularProducts[$productId] = $product; } } // process the remainder of the items if (!empty($regularProducts)) { try { $xml = ISC_ADMIN_EBAY_OPERATIONS::addItems($regularProducts, $template); } catch (ISC_EBAY_API_REQUEST_EXCEPTION $ex) { $xml = $ex->getResponseXML(); // if we have item level data then we want to process the results to get any errors for each item // otherwise, throw the exception and it will get caught in the job as a per-request level error if (!isset($xml->AddItemResponseContainer)) { throw $ex; } } // process each add item response foreach ($xml->AddItemResponseContainer as $item) { $productId = (int)$item->CorrelationID; $results[] = new ISC_ADMIN_EBAY_LIST_ITEM_RESULT($regularProducts[$productId], $item); } } return $results; }