Ejemplo n.º 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;
 }
Ejemplo n.º 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;
}
Ejemplo n.º 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');
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 public function hookDeleteProduct($params)
 {
     if (!isset($params['product']->id)) {
         return false;
     }
     $ebay_profile = EbayProfile::getCurrent();
     EbaySynchronizer::endProductOnEbay(new EbayRequest(), $ebay_profile, $this->context, $this->ebay_country->getIdLang(), null, $params['product']->id);
 }
Ejemplo n.º 6
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;
    }