public function ajaxProductSync() { $nb_products = EbaySynchronizer::getNbSynchronizableProducts($this->ebay_profile); $products = EbaySynchronizer::getProductsToSynchronize($this->ebay_profile, Tools::getValue('option')); $nb_products_less = EbaySynchronizer::getNbProductsLess($this->ebay_profile, Tools::getValue('option'), (int) $this->ebay_profile->getConfiguration('EBAY_SYNC_LAST_PRODUCT')); // Send each product on eBay if (count($products)) { $this->ebay_profile->setConfiguration('EBAY_SYNC_LAST_PRODUCT', (int) $products[0]['id_product']); EbaySynchronizer::syncProducts($products, $this->context, $this->ebay_profile->id_lang, 'SYNC_FROM_MODULE_BACK'); // we cheat a bit to display a consistent number of products done $nb_products_done = min($nb_products - $nb_products_less + 1, $nb_products); echo 'KO|<br /><br /> <img src="../modules/ebay/views/img/loading-small.gif" border="0" /> ' . $this->l('Products') . ' : ' . $nb_products_done . ' / ' . $nb_products . '<br /><br />'; } else { if (file_exists(dirname(__FILE__) . '/log/syncError.php')) { global $all_error; include dirname(__FILE__) . '/log/syncError.php'; if (count($all_error) == 0) { $msg = $this->l('Settings updated') . ' (' . $this->l('Option') . ' ' . $this->ebay_profile->getConfiguration('EBAY_SYNC_PRODUCTS_MODE') . ' : ' . ($nb_products - $nb_products_less) . ' / ' . $nb_products . ' ' . $this->l('product(s) sync with eBay') . ')<br/><br/>'; } else { $msg = ''; } $msg .= $this->l('Some products have not been listed successfully due to the error(s) below') . '<br/>'; foreach ($all_error as $error) { $products_details = '<br /><u>' . $this->l('Product(s) concerned') . ' :</u>'; foreach ($error['products'] as $product) { $products_details .= '<br />- ' . $product; } $msg .= $error['msg'] . '<br />' . $products_details; } echo 'OK|' . $this->displayError($msg); if ($itemConditionError) { //Add a specific message for item condition error $message = $this->l('The item condition value defined in your configuration is not supported in the eBay category.') . '<br/>'; $message .= $this->l('You can modify your item condition in the configuration settings (see supported conditions by categories here: http://pages.ebay.co.uk/help/sell/item-condition.html) '); $message .= $this->l('A later version of the module will allow you to specify item conditions by category'); echo $this->displayError($message); } echo '<style>#content .alert { text-align: left; width: 875px; }</style>'; @unlink(dirname(__FILE__) . '/log/syncError.php'); } else { echo 'OK|' . $this->displayConfirmation($this->l('Settings updated') . ' (' . $this->l('Option') . ' ' . $this->ebay_profile->getConfiguration('EBAY_SYNC_PRODUCTS_MODE') . ' : ' . ($nb_products - $nb_products_less) . ' / ' . $nb_products . ' ' . $this->l('product(s) sync with eBay') . ')'); } } }