Ejemplo n.º 1
0
 public function __construct()
 {
     /** Backward compatibility */
     require dirname(__FILE__) . '/../backward_compatibility/backward.php';
     $this->ebay_country = EbayCountrySpec::getInstanceByKey(Configuration::get('EBAY_COUNTRY_DEFAULT'), $this->dev);
     $this->itemConditionError = false;
     /**
      * 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();
     }
 }
Ejemplo n.º 2
0
 function getContent()
 {
     $ebay_country = EbayCountrySpec::getInstanceByKey($this->ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT'));
     $help_file = dirname(__FILE__) . '/../../help/help-' . Tools::strtolower($ebay_country->getDocumentationLang()) . '.html';
     if (!file_exists($help_file)) {
         $help_file = dirname(__FILE__) . '/../../help/help-en.html';
     }
     return Tools::file_get_contents($help_file);
 }
 function getContent()
 {
     $configs = Configuration::getMultiple(array('EBAY_CATEGORY_LOADED_' . $this->ebay_profile->ebay_site_id, 'EBAY_SECURITY_TOKEN'));
     $ebay_request = new EbayRequest();
     $user_profile = $ebay_request->getUserProfile($this->ebay_profile->ebay_user_identifier);
     $store_categories = EbayStoreCategory::getStoreCategories($this->ebay_profile->id);
     $not_compatible_names = array();
     if ($store_categories['not_compatible']) {
         foreach ($store_categories['not_compatible'] as $cat) {
             $not_compatible_names[] = $cat['name'];
         }
     }
     $template_vars = array('configs' => $configs, '_path' => $this->path, 'controller' => Tools::getValue('controller'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'tab' => Tools::getValue('tab'), 'nb_categorie' => count(Category::getCategories($this->context->cookie->id_lang, true, false)), 'has_store_categories' => count($store_categories['compatible']) > 1, 'not_compatible_store_categories' => implode(', ', $not_compatible_names), 'has_ebay_shop' => (bool) ($user_profile && $user_profile['StoreUrl']), 'ebay_store_url' => EbayCountrySpec::getProUrlBySiteId($this->ebay_profile->ebay_site_id));
     return $this->display('form_store_categories.tpl', $template_vars);
 }
 function getContent()
 {
     // Loading config currency
     $config_currency = new Currency((int) $this->ebay_profile->getConfiguration('EBAY_CURRENCY'));
     $url_vars = array('id_tab' => '1', 'section' => 'parameters');
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $url_vars['controller'] = Tools::getValue('controller');
     } else {
         $url_vars['tab'] = Tools::getValue('tab');
     }
     $url = $this->_getUrl($url_vars);
     $ebayShop = $this->ebay_profile->getConfiguration('EBAY_SHOP') ? $this->ebay_profile->getConfiguration('EBAY_SHOP') : $this->ebay->StoreName;
     $ebayShopValue = Tools::getValue('ebay_shop', $ebayShop);
     $ebay_country = EbayCountrySpec::getInstanceByKey($this->ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT'));
     $createShopUrl = 'http://cgi3.ebay.' . $ebay_country->getSiteExtension() . '/ws/eBayISAPI.dll?CreateProductSubscription&&productId=3&guest=1';
     $ebay_request = new EbayRequest();
     $ebay_sign_in_url = $ebay_request->getLoginUrl() . '?SignIn&runame=' . $ebay_request->runame . '&SessID=' . $this->context->cookie->eBaySession;
     $returns_policy_configuration = $this->ebay_profile->getReturnsPolicyConfiguration();
     $returnsConditionAccepted = Tools::getValue('ebay_returns_accepted_option', Configuration::get('EBAY_RETURNS_ACCEPTED_OPTION'));
     $ebay_paypal_email = Tools::getValue('ebay_paypal_email', $this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL'));
     $shopPostalCode = Tools::getValue('ebay_shop_postalcode', $this->ebay_profile->getConfiguration('EBAY_SHOP_POSTALCODE'));
     $shopCountry = Tools::getValue('ebay_shop_country', $this->ebay_profile->getConfiguration('EBAY_SHOP_COUNTRY'));
     $ebayListingDuration = $this->ebay_profile->getConfiguration('EBAY_LISTING_DURATION') ? $this->ebay_profile->getConfiguration('EBAY_LISTING_DURATION') : 'GTC';
     $user_profile = $ebay_request->getUserProfile($this->ebay_profile->ebay_user_identifier);
     $is_multishop = version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive();
     $order_states = OrderState::getOrderStates($this->ebay_profile->id_lang);
     $current_order_state = $this->ebay_profile->getConfiguration('EBAY_SHIPPED_ORDER_STATE');
     if ($current_order_state === null) {
         foreach ($order_states as $order_state) {
             if ($order_state['template'] === 'shipped') {
                 // NDRArbuz: is this the best way to find it with no doubt?
                 $current_order_state = $order_state['id_order_state'];
                 break;
             }
         }
     }
     $smarty_vars = array('url' => $url, 'ebay_sign_in_url' => $ebay_sign_in_url, 'ebay_token' => Configuration::get('EBAY_SECURITY_TOKEN'), 'configCurrencysign' => $config_currency->sign, 'policies' => EbayReturnsPolicy::getReturnsPolicies(), 'catLoaded' => !Configuration::get('EBAY_CATEGORY_LOADED_' . $this->ebay_profile->ebay_site_id), 'createShopUrl' => $createShopUrl, 'ebayCountry' => EbayCountrySpec::getInstanceByKey($this->ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT')), 'ebayReturns' => preg_replace('#<br\\s*?/?>#i', "\n", $this->ebay_profile->getReturnsPolicyConfiguration()->ebay_returns_description), 'ebayShopValue' => $ebayShopValue, 'shopPostalCode' => Tools::getValue('ebay_shop_postalcode', $this->ebay_profile->getConfiguration('EBAY_SHOP_POSTALCODE')), 'listingDurations' => $this->_getListingDurations(), 'ebayShop' => $this->ebay_profile->getConfiguration('EBAY_SHOP'), 'ebay_paypal_email' => Tools::getValue('ebay_paypal_email', $this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')), 'returnsConditionAccepted' => Tools::getValue('ebay_returns_accepted_option', $returns_policy_configuration->ebay_returns_accepted_option), 'automaticallyRelist' => $this->ebay_profile->getConfiguration('EBAY_AUTOMATICALLY_RELIST'), 'ebay_paypal_email' => $ebay_paypal_email, 'returnsConditionAccepted' => $returnsConditionAccepted, 'ebayListingDuration' => $ebayListingDuration, 'automaticallyRelist' => Configuration::get('EBAY_AUTOMATICALLY_RELIST'), 'is_multishop' => $is_multishop, 'within_values' => unserialize(Configuration::get('EBAY_RETURNS_WITHIN_VALUES')), 'within' => $returns_policy_configuration->ebay_returns_within, 'whopays_values' => unserialize(Configuration::get('EBAY_RETURNS_WHO_PAYS_VALUES')), 'whopays' => $returns_policy_configuration->ebay_returns_who_pays, 'activate_mails' => Configuration::get('EBAY_ACTIVATE_MAILS'), 'hasEbayBoutique' => isset($user_profile['StoreUrl']) && !empty($user_profile['StoreUrl']) ? true : false, 'currencies' => TotCompatibility::getCurrenciesByIdShop($this->ebay_profile->id_shop), 'current_currency' => (int) $this->ebay_profile->getConfiguration('EBAY_CURRENCY'), 'ebay_shop_countries' => EbayCountrySpec::getCountries(false), 'current_ebay_shop_country' => $shopCountry, 'send_tracking_code' => (bool) $this->ebay_profile->getConfiguration('EBAY_SEND_TRACKING_CODE'), 'order_states' => $order_states, 'current_order_state' => $current_order_state, 'immediate_payment' => (bool) $this->ebay_profile->getConfiguration('EBAY_IMMEDIATE_PAYMENT'));
     if (Tools::getValue('relogin')) {
         $this->ebay->login();
         $smarty_vars = array_merge($smarty_vars, array('relogin' => true, 'redirect_url' => $ebay_request->getLoginUrl() . '?SignIn&runame=' . $ebay_request->runame . '&SessID=' . $this->context->cookie->eBaySession));
     } else {
         $smarty_vars['relogin'] = false;
     }
     if (Tools::getValue('action') == 'regenerate_token') {
         $smarty_vars['check_token_tpl'] = $this->ebay->_displayCheckToken();
     }
     return $this->display('formParameters.tpl', $smarty_vars);
 }
Ejemplo n.º 5
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.º 6
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;
    }
Ejemplo n.º 7
0
 * 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__) . '/../classes/EbayCountrySpec.php';
include_once dirname(__FILE__) . '/../classes/EbayProductConfiguration.php';
if (!Tools::getValue('token') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    die('ERROR : INVALID TOKEN');
}
$ebay = new Ebay();
$ebay_country = EbayCountrySpec::getInstanceByKey(Configuration::get('EBAY_COUNTRY_DEFAULT'));
$ebay_request = new EbayRequest();
$id_lang = $ebay_country->getIdLang();
$id_ebay_profile = (int) Tools::getValue('id_ebay_profile');
$id_product = (int) Tools::getValue('product');
$is_one_five = version_compare(_PS_VERSION_, '1.5', '>');
$sql = 'SELECT pa.`id_product_attribute`,
		sa.`quantity`           AS stock,
		al.`name`               AS name,
		ep.`id_product_ref`     AS id_product_ref
	FROM `' . _DB_PREFIX_ . 'product_attribute` pa
	
	INNER JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac
	ON pac.`id_product_attribute` = pa.`id_product_attribute`
	
	INNER JOIN `' . _DB_PREFIX_ . 'attribute` a
Ejemplo n.º 8
0
 /**
  * Get Instance for Ebay Country
  * @param  string          $key Key of country
  * @param  boolean         $dev If module work in debug
  * @return EbayCountrySpec Ebay country
  */
 public static function getInstanceByKey($key, $dev = false)
 {
     if (isset(self::$country_data[$key])) {
         $iso_code = self::$country_data[$key]['iso_code'];
         $id_country = Country::getByIso($iso_code);
     } else {
         $id_country = Configuration::get('PS_COUNTRY_DEFAULT');
     }
     $ebay_country = new EbayCountrySpec(new Country($id_country));
     $ebay_country->setDev($dev);
     $ebay_country->ebay_iso = is_numeric($key) ? self::getKeyForEbayCountry() : $key;
     return $ebay_country;
 }
Ejemplo n.º 9
0
 /**
  * Register Form Config Methods
  **/
 private function _displayFormRegister()
 {
     $ebay = new EbayRequest();
     $smarty_vars = array();
     if (Tools::getValue('relogin')) {
         $session_id = $ebay->login();
         $this->context->cookie->eBaySession = $session_id;
         Configuration::updateValue('EBAY_API_SESSION', $session_id, false, 0, 0);
         $smarty_vars = array_merge($smarty_vars, array('relogin' => true, 'redirect_url' => $ebay->getLoginUrl() . '?SignIn&runame=' . $ebay->runame . '&SessID=' . $this->context->cookie->eBaySession));
     } else {
         $smarty_vars['relogin'] = false;
     }
     $logged = !empty($this->context->cookie->eBaySession) && Tools::getValue('action') == 'logged';
     $smarty_vars['logged'] = $logged;
     $id_shop = version_compare(_PS_VERSION_, '1.5', '>') ? Shop::getContextShopID() : Shop::getCurrentShop();
     if ($logged) {
         if ($ebay_username = Tools::getValue('eBayUsernamesList')) {
             if ($ebay_username == -1) {
                 $ebay_username = Tools::getValue('eBayUsername');
             }
             $this->context->cookie->eBayUsername = $ebay_username;
             $this->ebay_profile = EbayProfile::getByLangShopSiteAndUsername((int) Tools::getValue('ebay_language'), $id_shop, Tools::getValue('ebay_country'), $ebay_username, EbayProductTemplate::getContent($this, $this->smarty));
             EbayProfile::setProfile($this->ebay_profile->id);
         }
         $smarty_vars['check_token_tpl'] = $this->_displayCheckToken();
     } else {
         if (empty($this->context->cookie->eBaySession)) {
             $session_id = $ebay->login();
             $this->context->cookie->eBaySession = $session_id;
             Configuration::updateValue('EBAY_API_SESSION', $session_id, false, 0, 0);
             $this->context->cookie->write();
         }
         if (isset($this->ebay_profile->id_shop)) {
             $ebay_profiles = EbayProfile::getProfilesByIdShop($this->ebay_profile->id_shop);
         } else {
             $ebay_profiles = array();
         }
         foreach ($ebay_profiles as &$profile) {
             $profile['site_extension'] = EbayCountrySpec::getSiteExtensionBySiteId($profile['ebay_site_id']);
         }
         $smarty_vars = array_merge($smarty_vars, array('action_url' => $_SERVER['REQUEST_URI'] . '&action=logged', 'ebay_username' => $this->context->cookie->eBayUsername, 'window_open_url' => '?SignIn&runame=' . $ebay->runame . '&SessID=' . $this->context->cookie->eBaySession, 'ebay_countries' => EbayCountrySpec::getCountries($ebay->getDev()), 'default_country' => EbayCountrySpec::getKeyForEbayCountry(), 'ebay_user_identifiers' => EbayProfile::getEbayUserIdentifiers(), 'ebay_profiles' => $ebay_profiles, 'languages' => Language::getLanguages(true, $this->ebay_profile ? $this->ebay_profile->id_shop : $id_shop)));
     }
     $this->smarty->assign($smarty_vars);
     return $this->display(__FILE__, 'views/templates/hook/formRegister.tpl');
 }
    public static function getMultiVarToNonMultiSku($ebay_profile, $context)
    {
        $cat_with_problem = array();
        $sql_get_cat_non_multi_sku = 'SELECT * FROM ' . _DB_PREFIX_ . 'ebay_category_configuration AS ecc
			INNER JOIN ' . _DB_PREFIX_ . 'ebay_category AS ec ON ecc.id_ebay_category = ec.id_ebay_category
			WHERE ecc.id_ebay_profile = ' . (int) $ebay_profile->id . ' GROUP BY name';
        foreach (Db::getInstance()->ExecuteS($sql_get_cat_non_multi_sku) as $cat) {
            if ($cat['is_multi_sku'] != 1 && EbayCategory::getInheritedIsMultiSku($cat['id_category_ref'], $ebay_profile->ebay_site_id) != 1) {
                $catProblem = 0;
                $category = new Category($cat['id_category']);
                $ebay_country = EbayCountrySpec::getInstanceByKey($ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT'));
                $products = $category->getProductsWs($ebay_country->getIdLang(), 0, 300);
                foreach ($products as $product_ar) {
                    $product = new Product($product_ar['id']);
                    $combinations = version_compare(_PS_VERSION_, '1.5', '>') ? $product->getAttributeCombinations($context->cookie->id_lang) : $product->getAttributeCombinaisons($context->cookie->id_lang);
                    if (count($combinations) > 0 && !$catProblem) {
                        $cat_with_problem[] = $cat['name'];
                        $catProblem = 1;
                    }
                }
            }
        }
        return $cat_with_problem;
    }
Ejemplo n.º 11
0
 private function _displayFormParameters()
 {
     // Loading config currency
     $config_currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
     $url_vars = array('id_tab' => '1', 'section' => 'parameters');
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $url_vars['controller'] = Tools::safeOutput(Tools::getValue('controller'));
     } else {
         $url_vars['tab'] = Tools::safeOutput(Tools::getValue('tab'));
     }
     $url = $this->_getUrl($url_vars);
     $ebay_identifier = Tools::safeOutput(Tools::getValue('ebay_identifier', Configuration::get('EBAY_IDENTIFIER'))) . '" ' . (Tools::getValue('ebay_identifier', Configuration::get('EBAY_IDENTIFIER')) != '' ? ' readonly="readonly"' : '');
     $ebayShop = Configuration::get('EBAY_SHOP') ? Configuration::get('EBAY_SHOP') : $this->StoreName;
     $ebayShopValue = Tools::safeOutput(Tools::getValue('ebay_shop', $ebayShop));
     $createShopUrl = 'http://cgi3.ebay.' . $this->ebay_country->getSiteExtension() . '/ws/eBayISAPI.dll?CreateProductSubscription&&productId=3&guest=1';
     $ebay = new EbayRequest();
     $ebay_sign_in_url = $ebay->getLoginUrl() . '?SignIn&runame=' . $ebay->runame . '&SessID=' . $this->context->cookie->eBaySession;
     $smarty_vars = array('url' => $url, 'ebay_sign_in_url' => $ebay_sign_in_url, 'ebay_token' => Configuration::get('EBAY_SECURITY_TOKEN'), 'ebayIdentifier' => $ebay_identifier, 'configCurrencysign' => $config_currency->sign, 'policies' => $this->_getReturnsPolicies(), 'catLoaded' => !Configuration::get('EBAY_CATEGORY_LOADED'), 'createShopUrl' => $createShopUrl, 'ebayCountry' => EbayCountrySpec::getInstanceByKey(Configuration::get('EBAY_COUNTRY_DEFAULT')), 'ebayReturns' => preg_replace('#<br\\s*?/?>#i', "\n", Configuration::get('EBAY_RETURNS_DESCRIPTION')), 'ebayShopValue' => $ebayShopValue, 'shopPostalCode' => Tools::safeOutput(Tools::getValue('ebay_shop_postalcode', Configuration::get('EBAY_SHOP_POSTALCODE'))), 'listingDurations' => $this->_getListingDurations(), 'ebayShop' => Configuration::get('EBAY_SHOP'), 'ebay_paypal_email' => Tools::safeOutput(Tools::getValue('ebay_paypal_email', Configuration::get('EBAY_PAYPAL_EMAIL'))), 'returnsConditionAccepted' => Tools::getValue('ebay_returns_accepted_option', Configuration::get('EBAY_RETURNS_ACCEPTED_OPTION')), 'ebayListingDuration' => Configuration::get('EBAY_LISTING_DURATION'), 'automaticallyRelist' => Configuration::get('EBAY_AUTOMATICALLY_RELIST'), 'sizes' => ImageType::getImagesTypes('products'), 'sizedefault' => (int) Configuration::get('EBAY_PICTURE_SIZE_DEFAULT'), 'sizebig' => (int) Configuration::get('EBAY_PICTURE_SIZE_BIG'), 'sizesmall' => (int) Configuration::get('EBAY_PICTURE_SIZE_SMALL'), 'within_values' => unserialize(Configuration::get('EBAY_RETURNS_WITHIN_VALUES')), 'within' => Configuration::get('EBAY_RETURNS_WITHIN'), 'whopays_values' => unserialize(Configuration::get('EBAY_RETURNS_WHO_PAYS_VALUES')), 'whopays' => Configuration::get('EBAY_RETURNS_WHO_PAYS'));
     if (Tools::getValue('relogin')) {
         $this->login();
         $smarty_vars = array_merge($smarty_vars, array('relogin' => true, 'redirect_url' => $ebay->getLoginUrl() . '?SignIn&runame=' . $ebay->runame . '&SessID=' . $this->context->cookie->eBaySession));
     } else {
         $smarty_vars['relogin'] = false;
     }
     if (Tools::getValue('action') == 'regenerate_token') {
         $smarty_vars['check_token_tpl'] = $this->_displayCheckToken();
     }
     $this->smarty->assign($smarty_vars);
     return $this->display(dirname(__FILE__), '/views/templates/hook/formParameters.tpl');
 }
Ejemplo n.º 12
0
 public static function getEbayUrl($reference, $mode_dev = false)
 {
     $ebay_site_id = Db::getInstance()->getValue('SELECT ep.`ebay_site_id`
         FROM `' . _DB_PREFIX_ . 'ebay_profile` ep
         INNER JOIN `' . _DB_PREFIX_ . 'ebay_product` ep1
         ON ep.`id_ebay_profile` = ep1.`id_ebay_profile`
         AND ep1.`id_product_ref` = \'' . pSQL($reference) . '\'');
     if (!$ebay_site_id) {
         return '';
     }
     $site_extension = EbayCountrySpec::getSiteExtensionBySiteId($ebay_site_id);
     return 'http://cgi' . ($mode_dev ? '.sandbox' : '') . '.ebay.' . $site_extension . '/ws/eBayISAPI.dll?ViewItem&item=' . $reference . '&ssPageName=STRK:MESELX:IT&_trksid=p3984.m1555.l2649#ht_632wt_902';
 }
Ejemplo n.º 13
0
 * 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-2013 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__) . '/../classes/EbayCountrySpec.php';
include_once dirname(__FILE__) . '/../classes/EbayProductConfiguration.php';
if (!Tools::getValue('token') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    die('ERROR : INVALID TOKEN');
}
$ebay_country = new EbayCountrySpec();
$id_lang = $ebay_country->getIdLang();
$is_one_five = version_compare(_PS_VERSION_, '1.5', '>');
$sql = 'SELECT p.`id_product` as id, pl.`name`, epc.`blacklisted`, epc.`extra_images`
		FROM `' . _DB_PREFIX_ . 'product` p';
$sql .= $is_one_five ? Shop::addSqlAssociation('product', 'p') : '';
$sql .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
			ON (p.`id_product` = pl.`id_product`
			AND pl.`id_lang` = ' . (int) $id_lang;
$sql .= $is_one_five ? Shop::addSqlRestrictionOnLang('pl') : '';
$sql .= ')
		LEFT JOIN `' . _DB_PREFIX_ . 'ebay_product_configuration` epc
			ON p.`id_product` = epc.`id_product`
		WHERE ';
$sql .= $is_one_five ? ' product_shop.`id_shop` = 1 AND ' : '';
$sql .= ' p.`id_category_default` = ' . (int) Tools::getValue('category');
Ejemplo n.º 14
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;
}