예제 #1
0
 /**
  * Updates Ebay API Token and stores it
  *
  * Returns true is sucessful, false otherwise
  *
  * @return boolean
  */
 public static function updateAPIToken()
 {
     $profile_data = explode('_', Configuration::get('EBAY_CURRENT_PROFILE'));
     $request = new EbayRequest($profile_data[0]);
     $ebay_profile = EbayProfile::getCurrent(false);
     //		if ($token = $request->fetchToken(Configuration::get('EBAY_API_USERNAME', null, 0, 0), Configuration::get('EBAY_API_SESSION', null, 0, 0)))
     if ($token = $request->fetchToken($ebay_profile->ebay_user_identifier, Configuration::get('EBAY_API_SESSION', null, 0, 0))) {
         $ebay_profile->setToken($token);
         //Configuration::updateValue('EBAY_API_TOKEN', $token, false, 0, 0);
         Configuration::updateValue('EBAY_TOKEN_REGENERATE', false, false, 0, 0);
         return true;
     }
     return false;
 }
예제 #2
0
/**
 * 2007-2015 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author    PrestaShop SA <*****@*****.**>
 *  @copyright 2007-2015 PrestaShop SA
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
function upgrade_module_1_8($module)
{
    include dirname(__FILE__) . '/sql/sql-upgrade-1-8.php';
    if (!empty($sql) && is_array($sql)) {
        foreach ($sql as $request) {
            if (!Db::getInstance()->execute($request)) {
                return false;
            }
        }
    }
    // upgrade existing profiles
    $profiles = EbayProfile::getProfilesByIdShop();
    foreach ($profiles as $profile) {
        $ebay_profile = new EbayProfile($profile['id_ebay_profile']);
        // set id_lang if not set
        if (!$profile['id_lang']) {
            $ebay_profile->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
            $ebay_profile->save();
        }
        if ($ebay_profile->ebay_site_id) {
            $ebay_shop_country = EbayCountrySpec::getIsoCodeBySiteId($ebay_profile->ebay_site_id);
            $ebay_site_id = $ebay_profile->ebay_site_id;
        } else {
            if ($ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT')) {
                $ebay_shop_country = $ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT');
            } else {
                $ebay_shop_country = 'fr';
                $ebay_profile->setConfiguration('EBAY_COUNTRY_DEFAULT', $ebay_shop_country);
            }
            $ebay_profile->ebay_site_id = EbayCountrySpec::getSiteIdByIsoCode($ebay_shop_country);
            $ebay_profile->save();
            $ebay_site_id = $ebay_profile->ebay_site_id;
        }
        // we set EBAY_SHOP_COUNTRY
        $ebay_profile->setConfiguration('EBAY_SHOP_COUNTRY', $ebay_shop_country);
        // update ebay_category
        Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_category', array('id_country' => $ebay_site_id), 'UPDATE');
        if (Configuration::get('EBAY_CATEGORY_LOADED')) {
            Configuration::updateValue('EBAY_CATEGORY_LOADED_' . $ebay_site_id, 1, false, 0, 0);
        }
        // update ebay_category_specific
        Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_category_specific', array('ebay_site_id' => $ebay_site_id), 'UPDATE');
        // update ebay_product_configuration
        $ebay_profile = EbayProfile::getCurrent();
        Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_product_configuration', array('id_ebay_profile' => $ebay_profile->id), 'UPDATE');
    }
    return true;
}
예제 #3
0
 public function __construct($id_ebay_profile = null, $context = null)
 {
     /** Backward compatibility */
     require dirname(__FILE__) . '/../backward_compatibility/backward.php';
     $this->itemConditionError = false;
     $this->debug = (bool) Configuration::get('EBAY_ACTIVATE_LOGS');
     if ($id_ebay_profile) {
         $this->ebay_profile = new EbayProfile($id_ebay_profile);
     } else {
         $this->ebay_profile = EbayProfile::getCurrent();
     }
     if ($this->ebay_profile) {
         $this->ebay_country = EbayCountrySpec::getInstanceByKey($this->ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT'), $this->dev);
     } else {
         $this->ebay_country = EbayCountrySpec::getInstanceByKey('gb');
     }
     if ($context) {
         $this->context = $context;
     }
     /**
      * Sandbox params
      **/
     $this->devID = '1db92af1-2824-4c45-8343-dfe68faa0280';
     if ($this->dev) {
         $this->appID = 'Prestash-2629-4880-ba43-368352aecc86';
         $this->certID = '6bd3f4bd-3e21-41e8-8164-7ac733218122';
         $this->apiUrl = 'https://api.sandbox.ebay.com/ws/api.dll';
         $this->compatibility_level = 719;
         $this->runame = 'Prestashop-Prestash-2629-4-hpehxegu';
         $this->loginURL = $this->ebay_country->getSiteSignin();
     } else {
         $this->appID = 'Prestash-70a5-419b-ae96-f03295c4581d';
         $this->certID = '71d26dc9-b36b-4568-9bdb-7cb8af16ac9b';
         $this->apiUrl = 'https://api.ebay.com/ws/api.dll';
         $this->compatibility_level = 741;
         $this->runame = 'Prestashop-Prestash-70a5-4-pepwa';
         $this->loginURL = $this->ebay_country->getSiteSignin();
     }
     $this->write_api_logs = Configuration::get('EBAY_API_LOGS');
 }
예제 #4
0
    public static function getByLangShopSiteAndUsername($id_lang, $id_shop, $ebay_country, $ebay_user_identifier, $template_content)
    {
        $ebay_country_spec = EbayCountrySpec::getInstanceByKey($ebay_country);
        $ebay_site_id = $ebay_country_spec->getSiteID();
        $sql = 'SELECT `id_ebay_profile` 
			FROM `' . _DB_PREFIX_ . 'ebay_profile` ep
			WHERE ep.`id_lang` = ' . (int) $id_lang . '
			AND ep.`id_shop` = ' . (int) $id_shop . '
			AND ep.`ebay_site_id` = ' . (int) $ebay_site_id . '
			AND ep.`ebay_user_identifier` = \'' . pSQL($ebay_user_identifier) . '\'';
        if ($id_profile = Db::getInstance()->getValue($sql)) {
            return new EbayProfile($id_profile);
        }
        // otherwise create the eBay profile
        $ebay_profile = new EbayProfile();
        $ebay_profile->id_lang = $id_lang;
        $ebay_profile->id_shop = $id_shop;
        $ebay_profile->ebay_site_id = $ebay_site_id;
        $ebay_profile->ebay_user_identifier = $ebay_user_identifier;
        $returns_policy_configuration = new EbayReturnsPolicyConfiguration();
        $returns_policy_configuration->save();
        $ebay_profile->id_ebay_returns_policy_configuration = $returns_policy_configuration->id;
        $ebay_profile->save();
        $ebay_profile->setConfiguration('EBAY_COUNTRY_DEFAULT', $ebay_country);
        $ebay_profile->setPicturesSettings();
        $ebay_profile->setDefaultConfig($template_content);
        return $ebay_profile;
    }
예제 #5
0
 /**
  * Exports the product to eBay and updates the ebay_product table
  *
  **/
 private static function _exportProductToEbay($product, $data, $id_ebay_profile, $ebay_category, $ebay, $date, $context, $id_lang)
 {
     $ebay_profile = new EbayProfile($id_ebay_profile);
     $id_currency = (int) $ebay_profile->getConfiguration('EBAY_CURRENCY');
     if (count($data['variations'])) {
         // the product is multivariation
         if (EbaySynchronizer::_isProductMultiSku($ebay_category, $product->id, $id_lang, $ebay_profile->ebay_site_id)) {
             // the category accepts multisku products and there is variables matching
             $data['item_specifics'] = EbaySynchronizer::_getProductItemSpecifics($ebay_category, $product, $id_lang);
             $data['description'] = EbaySynchronizer::_getMultiSkuItemDescription($data, $id_currency);
             if ($item_id = EbayProduct::getIdProductRef($product->id, $ebay_profile->ebay_user_identifier, $ebay_profile->ebay_site_id)) {
                 $data['itemID'] = $item_id;
                 if (!EbaySynchronizer::_hasVariationProducts($data['variations'])) {
                     EbaySynchronizer::endProductOnEbay($ebay, $ebay_profile, $context, $id_lang, $item_id);
                 } else {
                     $ebay = EbaySynchronizer::_updateMultiSkuItem($product->id, $data, $id_ebay_profile, $ebay, $date);
                 }
             } else {
                 EbaySynchronizer::_addMultiSkuItem($product->id, $data, $id_ebay_profile, $ebay, $date);
             }
         } else {
             // No Multi Sku case so we do multiple products from a multivariation product
             $data['item_specifics'] = EbaySynchronizer::_getProductItemSpecifics($ebay_category, $product, $id_lang, true);
             foreach ($data['variations'] as $variation) {
                 $data_variation = EbaySynchronizer::_getVariationData($data, $variation, $id_currency);
                 // Check if product exists on eBay
                 if ($itemID = EbayProduct::getIdProductRef($product->id, $ebay_profile->ebay_user_identifier, $ebay_profile->ebay_site_id, $data_variation['id_attribute'])) {
                     $data_variation['itemID'] = $itemID;
                     if ($data_variation['quantity'] < 1) {
                         // no more products
                         EbaySynchronizer::endProductOnEbay($ebay, $ebay_profile, $context, $id_lang, $itemID);
                     } else {
                         EbaySynchronizer::_updateItem($product->id, $data_variation, $id_ebay_profile, $ebay, $date, $data_variation['id_attribute']);
                     }
                 } else {
                     EbaySynchronizer::_addItem($product->id, $data_variation, $id_ebay_profile, $ebay, $date, $data_variation['id_attribute']);
                 }
             }
         }
     } else {
         // the product is not a multivariation product
         $data['item_specifics'] = EbaySynchronizer::_getProductItemSpecifics($ebay_category, $product, $id_lang);
         $data['description'] = EbaySynchronizer::_getItemDescription($data, $id_currency);
         // Check if product exists on eBay
         if ($itemID = EbayProduct::getIdProductRef($product->id, $ebay_profile->ebay_user_identifier, $ebay_profile->ebay_site_id)) {
             $data['itemID'] = $itemID;
             // Delete or Update
             if ($data['quantity'] < 1) {
                 EbaySynchronizer::endProductOnEbay($ebay, $ebay_profile, $context, $id_lang, $itemID);
             } else {
                 EbaySynchronizer::_updateItem($product->id, $data, $id_ebay_profile, $ebay, $date);
             }
         } else {
             EbaySynchronizer::_addItem($product->id, $data, $id_ebay_profile, $ebay, $date);
         }
     }
     return $ebay;
 }
예제 #6
0
 /**
  * Tools Methods
  *
  * Set country
  *
  **/
 private function _getCountry()
 {
     $ebay_profile = EbayProfile::getCurrent();
     if ($ebay_profile) {
         $ebayCountry = self::getInstanceByKey($ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT'));
     } else {
         $ebayCountry = self::getInstanceByKey('gb');
     }
     $this->country = $ebayCountry->country;
     return $this->country;
 }
예제 #7
0
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author    PrestaShop SA <*****@*****.**>
 *  @copyright 2007-2015 PrestaShop SA
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
include_once dirname(__FILE__) . '/../../../config/config.inc.php';
include_once dirname(__FILE__) . '/../../../init.php';
include_once dirname(__FILE__) . '/../ebay.php';
$ebay = new Ebay();
$ebay_profile = new EbayProfile((int) Tools::getValue('profile'));
if (!Configuration::get('EBAY_SECURITY_TOKEN') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    return Tools::safeOutput(Tools::getValue('not_logged_str'));
}
$categories = Category::getCategories(Tools::getValue('id_lang'));
$category_list = $ebay->getChildCategories($categories, version_compare(_PS_VERSION_, '1.5', '>') ? 1 : 0, array(), '', Tools::getValue('s'));
$offset = 20;
$page = (int) Tools::getValue('p', 0);
if ($page < 2) {
    $page = 1;
}
$limit = $offset * ($page - 1);
$nb_categories = count($category_list);
$category_list = array_slice($category_list, $limit, $offset);
$ebay_category_list = Db::getInstance()->executeS('SELECT *
	FROM `' . _DB_PREFIX_ . 'ebay_category`
예제 #8
0
 public static function getTemplateTabConfiguration($id_ebay_profile)
 {
     $ebay_profile = new EbayProfile($id_ebay_profile);
     $ebay = new Ebay();
     if ($ebay_profile->getConfiguration('EBAY_PRODUCT_TEMPLATE_TITLE') == '') {
         return array('indicator' => 'wrong', 'indicatorBig' => 'wrong', 'message' => $ebay->l('You need to add something in your template title. Use the tags available to personnalize your product title on eBay', 'ebayvalidatortab'));
     }
     if ($ebay_profile->getConfiguration('EBAY_PRODUCT_TEMPLATE_TITLE') == '{TITLE}') {
         return array('indicator' => 'success', 'indicatorBig' => 'mind', 'message' => $ebay->l('You could improve your title template by adding informations about the items', 'ebayvalidatortab'));
     }
     return array('indicator' => 'success');
 }
예제 #9
0
 private function _postProcessConfig()
 {
     if ($id_ebay_profile = (int) Tools::getValue('ebay_profile')) {
         if (!EbayProfile::setProfile($id_ebay_profile)) {
             $this->html .= $this->displayError($this->l('Profile cannot be changed'));
         }
     }
 }
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author    PrestaShop SA <*****@*****.**>
 *  @copyright 2007-2015 PrestaShop SA
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
include_once dirname(__FILE__) . '/../../../config/config.inc.php';
include_once dirname(__FILE__) . '/../../../init.php';
include_once dirname(__FILE__) . '/../ebay.php';
$ebay = new Ebay();
$ebay_profile = new EbayProfile((int) Tools::getValue('profile'));
$ebay_request = new EbayRequest();
if (!Configuration::get('EBAY_SECURITY_TOKEN') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    return Tools::safeOutput(Tools::getValue('not_logged_str'));
}
$page = (int) Tools::getValue('p', 0);
if ($page < 2) {
    $page = 1;
}
$limit = 20;
$offset = $limit * ($page - 1);
$on_ebay_only = Tools::getValue('mode') == 'on_ebay';
$search = Tools::getValue('s');
$is_one_five = version_compare(_PS_VERSION_, '1.5', '>');
// to check if a product has attributes (multi-variations), we check if it has a "default_on" attribute in the product_attribute table
// this prevents us of doing a double "group by" which would complexify the query
예제 #11
0
    public function getProductsAndProfileByShop()
    {
        $res = array();
        foreach ($this->product_list as $product) {
            if ($product['id_ebay_profile']) {
                $ebay_profile = new EbayProfile((int) $product['id_ebay_profile']);
            } else {
                $sql = 'SELECT epr.`id_ebay_profile`
				FROM `' . _DB_PREFIX_ . 'ebay_product` epr
				WHERE epr.`id_product` = ' . (int) $product['id_product'];
                $id_ebay_profile = (int) Db::getInstance()->getValue($sql);
                if ($id_ebay_profile) {
                    $ebay_profile = new EbayProfile($id_ebay_profile);
                } else {
                    // case where the row in ebay_product has disappeared like if the product has been removed from eBay before sync
                    if (version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive()) {
                        $sql = 'SELECT `id_ebay_profile`
							FROM `' . _DB_PREFIX_ . 'ebay_profile` ep
							LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps
							ON ep.`id_shop` = ps.`id_shop`
							AND ps.`id_product` = ' . (int) $product['id_product'];
                        $id_ebay_profile = (int) Db::getInstance()->getValue($sql);
                        $ebay_profile = new EbayProfile($id_ebay_profile);
                    } else {
                        $ebay_profile = EbayProfile::getCurrent();
                    }
                }
            }
            if (!isset($res[$ebay_profile->id_shop])) {
                $res[$ebay_profile->id_shop] = array('id_ebay_profiles' => array($ebay_profile->id), 'id_products' => array());
            } elseif (!in_array($ebay_profile->id, $res[$ebay_profile->id_shop]['id_ebay_profiles'])) {
                $res[$ebay_profile->id_shop]['id_ebay_profiles'][] = $ebay_profile->id;
            }
            // $res[$ebay_profile->id_shop]['id_products'][] = $product['id_product'];
            $res[$ebay_profile->id_shop]['id_products'][] = array('id_product' => $product['id_product'], 'id_product_attribute' => $product['id_product_attribute']);
        }
        return $res;
    }
예제 #12
0
/**
 * 2007-2014 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author    PrestaShop SA <*****@*****.**>
 *  @copyright 2007-2014 PrestaShop SA
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
include dirname(__FILE__) . '/../../../config/config.inc.php';
if (!Tools::getValue('token') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    die('ERROR: Invalid Token');
}
include dirname(__FILE__) . '/../classes/EbayProfile.php';
echo EbayProfile::deleteById((int) Tools::getValue('profile'));
예제 #13
0
/**
 * Updates the template image links since the image files have moved
 *
 */
function upgrade_module_1_7($module)
{
    include dirname(__FILE__) . '/sql/sql-upgrade-1-7.php';
    if (!empty($sql) && is_array($sql)) {
        foreach ($sql as $request) {
            if (!Db::getInstance()->execute($request)) {
                return false;
            }
        }
    }
    Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'ebay_shipping SET id_zone = ' . (int) Configuration::get('EBAY_ZONE_NATIONAL') . ' WHERE international = 0');
    Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'ebay_shipping SET id_zone = ' . (int) Configuration::get('EBAY_ZONE_INTERNATIONAL') . ' WHERE international = 1');
    // create default profile(s)
    $is_multishop = version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive();
    $id_shop_default = (int) Configuration::get('PS_SHOP_DEFAULT') ? (int) Configuration::get('PS_SHOP_DEFAULT') : 1;
    // handle default returns policy
    if (!($id_returns_policy_configuration = EbayReturnsPolicyConfiguration::getDefaultObjectId())) {
        $id_returns_policy_configuration = EbayReturnsPolicyConfiguration::createPreviousDefaultConfiguration();
    }
    // handle default profile
    if (version_compare(_PS_VERSION_, '1.5', '<')) {
        $id_shops = array('1' => '1');
    } else {
        $id_shops = Shop::getShops(false, null, false);
    }
    foreach (array_keys($id_shops) as $id_shop) {
        if (!($profile = EbayProfile::getOneByIdShop($id_shop))) {
            $profile = new EbayProfile();
            $profile->id_shop = $id_shop;
        }
        $profile->ebay_user_identifier = Configuration::get('EBAY_IDENTIFIER');
        $ebay_country = EbayCountrySpec::getInstanceByKey(Configuration::get('EBAY_COUNTRY_DEFAULT'));
        $profile->ebay_site = $ebay_country->getSiteExtension();
        if ($id_shop_default == $id_shop) {
            $profile->id_ebay_returns_policy_configuration = $id_returns_policy_configuration;
        } else {
            $profile->id_ebay_returns_policy_configuration = EbayReturnsPolicyConfiguration::createPreviousDefaultConfiguration();
        }
        $profile->save();
        if ($id_shop_default == $id_shop) {
            $id_default_ebay_profile = $profile->id;
        }
        $configurations_to_update = array('EBAY_COUNTRY_DEFAULT', 'EBAY_ORDER_LAST_UPDATE', 'EBAY_DELIVERY_TIME', 'EBAY_PICTURE_SIZE_DEFAULT', 'EBAY_PICTURE_SIZE_SMALL', 'EBAY_PICTURE_SIZE_BIG', 'EBAY_LISTING_DURATION', 'EBAY_AUTOMATICALLY_RELIST', 'EBAY_LAST_RELIST', 'EBAY_SYNC_PRODUCTS_MODE', 'EBAY_ZONE_NATIONAL', 'EBAY_ZONE_INTERNATIONAL', 'EBAY_SHOP', 'EBAY_SHOP_POSTALCODE', 'EBAY_SYNC_OPTION_RESYNC', 'EBAY_SYNC_MODE', 'EBAY_SYNC_LAST_PRODUCT', 'EBAY_SPECIFICS_LAST_UPDATE', 'EBAY_PAYPAL_EMAIL');
        $configuration_to_update_html = array('EBAY_PRODUCT_TEMPLATE');
        EbayConfiguration::PSConfigurationsToEbayConfigurations($profile->id, $configurations_to_update, $configuration_to_update_html);
        $profile->setConfiguration('EBAY_PRODUCT_TEMPLATE_TITLE', '{TITLE}');
    }
    $configurations_to_delete = array_merge($configurations_to_update, array('EBAY_RETURNS_DESCRIPTION', 'EBAY_RETURNS_ACCEPTED_OPTION', 'EBAY_RETURNS_WITHIN', 'EBAY_RETURNS_WHO_PAYS'));
    foreach ($configurations_to_delete as $name) {
        Configuration::deleteByName($name);
    }
    // ebay_category_configuration table
    $tables = array('ebay_category_configuration', 'ebay_shipping_zone_excluded', 'ebay_shipping_international_zone', 'ebay_category_condition', 'ebay_category_condition_configuration', 'ebay_shipping', 'ebay_product');
    if (version_compare(_PS_VERSION_, '1.5', '<')) {
        foreach ($tables as $table) {
            Db::getInstance()->autoExecute(_DB_PREFIX_ . $table, array('id_ebay_profile' => $id_default_ebay_profile), 'UPDATE');
        }
    } else {
        foreach ($tables as $table) {
            Db::getInstance()->update($table, array('id_ebay_profile' => $id_default_ebay_profile));
        }
    }
    $sql = 'SELECT `id_ebay_order`, `id_order`
			FROM `' . _DB_PREFIX_ . 'ebay_order`';
    $res = Db::getInstance()->executeS($sql);
    foreach ($res as $row) {
        $data = array('id_ebay_order' => $row['id_ebay_order'], 'id_order' => $row['id_order']);
        if (version_compare(_PS_VERSION_, '1.5', '<')) {
            Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_order_order', $data, 'INSERT');
        } else {
            Db::getInstance()->insert('ebay_order_order', $data, false, true, Db::REPLACE);
        }
    }
    $module->setConfiguration('EBAY_VERSION', $module->version);
    // TODO: at some point we need to remove the id_order column of ebay_order which becomes useless
    // but we cannot do it before the data have moved
    return true;
}
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author    PrestaShop SA <*****@*****.**>
 *  @copyright 2007-2015 PrestaShop SA
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
include dirname(__FILE__) . '/../../../config/config.inc.php';
include dirname(__FILE__) . '/../classes/EbayCategorySpecific.php';
include dirname(__FILE__) . '/../classes/EbayCategoryCondition.php';
if (!Tools::getValue('token') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    die('ERROR : INVALID TOKEN');
}
$id_ebay_profile = (int) Tools::getValue('profile');
$ebay_profile = new EbayProfile($id_ebay_profile);
function loadItemsMap($row)
{
    return $row['id'];
}
/* Fix for limit db sql request in time */
sleep(1);
$category = new EbayCategory($ebay_profile, (int) Tools::getValue('ebay_category'));
if (!$ebay_profile->getConfiguration('EBAY_SPECIFICS_LAST_UPDATE') || $ebay_profile->getConfiguration('EBAY_SPECIFICS_LAST_UPDATE') < date('Y-m-d\\TH:i:s', strtotime('-3 days')) . '.000Z') {
    $time = time();
    $res = EbayCategorySpecific::loadCategorySpecifics($id_ebay_profile);
    $res &= EbayCategoryCondition::loadCategoryConditions($id_ebay_profile);
    if ($res) {
        $ebay_profile->setConfiguration('EBAY_SPECIFICS_LAST_UPDATE', date('Y-m-d\\TH:i:s.000\\Z'), false);
    }
}