/** * 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; }
/** * Displays the edit template form * */ public function editEbayTemplate() { GetLib('class.json'); $templateId = (int)$_GET['templateId']; try { $template = new ISC_ADMIN_EBAY_TEMPLATE($templateId); $this->template->assign('templateId', $templateId); $this->template->assign('formTitle', GetLang('EditEbayTemplate')); $this->template->assign('hasStore', (bool)GetConfig('EbayStore')); $this->template->assign('ebaySites', $this->getSupportedSites()); $this->template->assign('siteId', $template->getSiteId()); $this->template->assign('templateName', $template->getTemplateName()); $this->template->assign('templateIsDefault', $template->isDefaultTemplate()); $this->template->assign('isPrivateListing', $template->isPrivateListing()); // setup category details $primaryCategoryOptions = $template->getPrimaryCategoryOptions(); $secondaryCategoryOptions = $template->getSecondaryCategoryOptions(); $this->template->assign('primaryCategory', $primaryCategoryOptions['path']); $this->template->assign('primaryCategoryOptions', ISC_JSON::encode($primaryCategoryOptions)); $this->template->assign('categoryOptions', $primaryCategoryOptions); $this->template->assign('sellingMethod', $template->getSellingMethod()); try { if (empty ($secondaryCategoryOptions)) { $secondaryCategoryId = $template->getSecondaryCategoryId(); if (!empty ($secondaryCategoryId)) { $secondaryCategoryOptions = ''; $secondaryCategoryOptions = ISC_ADMIN_EBAY_CATEGORIES::getCategoryFeatures($secondaryCategoryId, $template->getSiteId()); $categoryPath = ISC_ADMIN_EBAY_CATEGORIES::getFormattedCategoryPath($secondaryCategoryId, $template->getSiteId()); $secondaryCategoryOptions['path'] = $categoryPath; } else { $secondaryCategoryOptions = ISC_ADMIN_EBAY_CATEGORIES::getCategoryOptionsFromId($template->getSecondaryCategoryId(), $template->getSiteId()); } } } catch (Exception $ex) { $secondaryCategoryOptions = array( 'category_id' => $template->getSecondaryCategoryId(), 'name' => $template->getSecondaryCategoryName(), 'path' => $template->getSecondaryCategoryName(), ); } if ($secondaryCategoryOptions) { $this->template->assign('secondaryCategoryOptionsData', $secondaryCategoryOptions); $this->template->assign('secondaryCategory', $secondaryCategoryOptions['path']); } $secCatNotSupportVariations = (isset ($secondaryCategoryOptions['variations_supported']) && $secondaryCategoryOptions['variations_supported'] == 0); $this->template->assign('secCatSelectedNotSupportVariations', ($secCatNotSupportVariations)); $this->template->assign('secondaryCategoryOptions', ISC_JSON::encode($secondaryCategoryOptions)); $this->template->assign('categoryFeaturesList', $this->template->render('ebay.template.featureslist.tpl')); $primaryStoreCategoryOptions = array(); if ($template->getPrimaryStoreCategoryId()) { $primaryStoreCategoryOptions = array( 'category_id' => $template->getPrimaryStoreCategoryId(), 'name' => $template->getPrimaryStoreCategoryName(), 'path' => $template->getPrimaryStoreCategoryName(), ); $this->template->assign('primaryStoreCategory', $primaryStoreCategoryOptions['path']); } $this->template->assign('primaryStoreCategoryOptions', ISC_JSON::encode($primaryStoreCategoryOptions)); $secondaryStoreCategoryOptions = array(); if ($template->getSecondaryStoreCategoryId()) { $secondaryStoreCategoryOptions = array( 'category_id' => $template->getSecondaryStoreCategoryId(), 'name' => $template->getSecondaryStoreCategoryName(), 'path' => $template->getSecondaryStoreCategoryName(), ); $this->template->assign('secondaryStoreCategory', $secondaryStoreCategoryOptions['path']); } $this->template->assign('secondaryStoreCategoryOptions', ISC_JSON::encode($secondaryStoreCategoryOptions)); $this->template->assign('sellingMethod', $template->getSellingMethod()); } catch (Exception $ex) { FlashMessage($ex->getMessage(), MSG_ERROR, 'index.php?ToDo=viewEbay'); } $GLOBALS['BreadcrumEntries'][GetLang('EditEbayTemplate')] = 'index.php?ToDo=editEbayTemplate'; $this->engine->PrintHeader(); $this->template->display('ebay.template.form.tpl'); $this->engine->PrintFooter(); }