Ejemplo n.º 1
0
 function getContent()
 {
     $is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>');
     // Load prestashop ebay's configuration
     $configs = Configuration::getMultiple(array('EBAY_CATEGORY_LOADED_' . $this->ebay_profile->ebay_site_id, 'EBAY_SECURITY_TOKEN'));
     // Check if the module is configured
     if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) {
         return $this->display('error_paypal_email.tpl', array('error_form_category', 'true'));
     }
     // Load categories only if necessary
     if (EbayCategoryConfiguration::getTotalCategoryConfigurations($this->ebay_profile->id) && Tools::getValue('section') != 'category') {
         $template_vars = array('isOneDotFive' => $is_one_dot_five, 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'form_categories' => EbaySynchronizer::getNbSynchronizableEbayCategorie($this->ebay_profile->id));
         return $this->display('pre_form_categories.tpl', $template_vars);
     }
     // Display eBay Categories
     $ebay_site_id = $this->ebay_profile->ebay_site_id;
     if (!isset($configs['EBAY_CATEGORY_LOADED_' . $ebay_site_id]) || !$configs['EBAY_CATEGORY_LOADED_' . $ebay_site_id] || !EbayCategory::areCategoryLoaded($ebay_site_id)) {
         $ebay_request = new EbayRequest();
         EbayCategory::insertCategories($ebay_site_id, $ebay_request->getCategories(), $ebay_request->getCategoriesSkuCompliancy());
         Configuration::updateValue('EBAY_CATEGORY_LOADED_' . $ebay_site_id, 1);
     }
     // Smarty
     $template_vars = array('alerts' => $this->_getAlertCategories(), 'tabHelp' => '&id_tab=7', 'id_lang' => $this->context->cookie->id_lang, 'id_ebay_profile' => $this->ebay_profile->id, '_path' => $this->path, 'configs' => $configs, '_module_dir_' => _MODULE_DIR_, 'isOneDotFive' => $is_one_dot_five, 'request_uri' => $_SERVER['REQUEST_URI'], 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'date' => pSQL(date('Ymdhis')), 'form_categories' => EbaySynchronizer::getNbSynchronizableEbayCategorie($this->ebay_profile->id), 'nb_categorie' => count(Category::getCategories($this->context->cookie->id_lang, true, false)));
     return $this->display('form_categories.tpl', $template_vars);
 }
 /**
  * Updates Ebay API Token and stores it
  *
  * Returns true is sucessful, false otherwise
  *
  * @return boolean
  */
 public static function updateAPIToken()
 {
     $request = new EbayRequest();
     if ($token = $request->fetchToken(Configuration::get('EBAY_API_USERNAME'), Configuration::get('EBAY_API_SESSION'))) {
         Configuration::updateValue('EBAY_API_TOKEN', $token, false, 0, 0);
         Configuration::updateValue('EBAY_TOKEN_REGENERATE', false);
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 public static function getCarriers($ebay_site_id)
 {
     if (EbayShippingService::getTotal($ebay_site_id)) {
         return EbayShippingService::getAll($ebay_site_id);
     }
     $ebay = new EbayRequest();
     $carriers = $ebay->getCarriers();
     foreach ($carriers as $carrier) {
         EbayShippingService::insert(array_map('pSQL', $carrier));
     }
     return $carriers;
 }
 public static function getDeliveryTimeOptions()
 {
     if (EbayDeliveryTimeOptions::getTotal()) {
         return EbayDeliveryTimeOptions::getAll();
     }
     $ebay = new EbayRequest();
     $delivery_time_options = $ebay->getDeliveryTimeOptions();
     foreach ($delivery_time_options as $delivery_time_option) {
         EbayDeliveryTimeOptions::insert(array_map('pSQL', $delivery_time_option));
     }
     return $delivery_time_options;
 }
 public static function getInternationalShippingLocations()
 {
     if (EbayShippingLocation::getTotal()) {
         return EbayShippingLocation::getEbayShippingLocations();
     }
     $ebay = new EbayRequest();
     $locations = $ebay->getInternationalShippingLocations();
     foreach ($locations as $location) {
         EbayShippingLocation::insert(array_map('pSQL', $location));
     }
     return $locations;
 }
Ejemplo n.º 6
0
    /**
     * Parse the data returned by the API and enter them in the table
     *
     **/
    public static function loadCategorySpecifics($id_ebay_profile)
    {
        $request = new EbayRequest($id_ebay_profile);
        $ebay_category_ids = EbayCategoryConfiguration::getEbayCategoryIds($id_ebay_profile);
        $ebay_profile = new EbayProfile($id_ebay_profile);
        foreach ($ebay_category_ids as $ebay_category_id) {
            $xml_data = $request->GetCategorySpecifics($ebay_category_id);
            if ($xml_data->Recommendations->NameRecommendation) {
                foreach ($xml_data->Recommendations->NameRecommendation as $recommendation) {
                    $required = isset($recommendation->ValidationRules->MinValues) && (int) $recommendation->ValidationRules->MinValues >= 1;
                    // if true can be used either in Item Specifics or VariationSpecifics
                    $can_variation = !(isset($recommendation->ValidationRules->VariationSpecifics) && (string) $recommendation->ValidationRules->VariationSpecifics == 'Disabled');
                    if (isset($recommendation->ValidationRules->SelectionMode)) {
                        if ((string) $recommendation->ValidationRules->SelectionMode == 'Prefilled') {
                            continue;
                        } elseif ((string) $recommendation->ValidationRules->SelectionMode == 'SelectionOnly') {
                            $selection_mode = EbayCategorySpecific::SELECTION_MODE_SELECTION_ONLY;
                        } else {
                            $selection_mode = EbayCategorySpecific::SELECTION_MODE_FREE_TEXT;
                        }
                    } else {
                        $selection_mode = EbayCategorySpecific::SELECTION_MODE_FREE_TEXT;
                    }
                    $values = array();
                    if (isset($recommendation->ValueRecommendation->Value)) {
                        foreach ($recommendation->ValueRecommendation as $value_recommendation) {
                            $values[] = (string) $value_recommendation->Value;
                        }
                    }
                    $db = Db::getInstance();
                    $db->execute('INSERT INTO `' . _DB_PREFIX_ . 'ebay_category_specific` (`id_category_ref`, `name`, `required`, `can_variation`, `selection_mode`, `ebay_site_id`)
						VALUES (' . (int) $ebay_category_id . ', \'' . pSQL((string) $recommendation->Name) . '\', ' . ($required ? 1 : 0) . ', ' . ($can_variation ? 1 : 0) . ', ' . ($selection_mode ? 1 : 0) . ', ' . (int) $ebay_profile->ebay_site_id . ')
						ON DUPLICATE KEY UPDATE `required` = ' . ($required ? 1 : 0) . ', `can_variation` = ' . ($can_variation ? 1 : 0) . ', `selection_mode` = ' . ($selection_mode ? 1 : 0));
                    $ebay_category_specific_id = $db->Insert_ID();
                    if (!$ebay_category_specific_id) {
                        $ebay_category_specific_id = $db->getValue('SELECT `id_ebay_category_specific`
							FROM `' . _DB_PREFIX_ . 'ebay_category_specific`
							WHERE `id_category_ref` = ' . (int) $ebay_category_id . '
							AND `ebay_site_id` = ' . (int) $ebay_profile->ebay_site_id . '
							AND `name` = \'' . pSQL((string) $recommendation->Name) . '\'');
                    }
                    $insert_data = array();
                    foreach ($values as $value) {
                        $insert_data[] = array('id_ebay_category_specific' => (int) $ebay_category_specific_id, 'value' => pSQL($value));
                    }
                    EbayCategorySpecificValue::insertIgnore($insert_data);
                }
            }
        }
        return true;
    }
Ejemplo n.º 7
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;
 }
 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);
 }
    /**
     *
     * Parse the data returned by the API for the eBay Category Conditions
     **/
    public static function loadCategoryConditions($id_ebay_profile)
    {
        $request = new EbayRequest($id_ebay_profile);
        $ebay_category_ids = EbayCategoryConfiguration::getEbayCategoryIds((int) $id_ebay_profile);
        $conditions = array();
        foreach ($ebay_category_ids as $category_id) {
            $xml_data = $request->GetCategoryFeatures($category_id);
            if (isset($xml_data->Category->ConditionEnabled)) {
                $condition_enabled = $xml_data->Category->ConditionEnabled;
            } else {
                $condition_enabled = $xml_data->SiteDefaults->ConditionEnabled;
            }
            if (!$condition_enabled) {
                return;
            }
            if (isset($xml_data->Category->ConditionValues->Condition)) {
                $xml_conditions = $xml_data->Category->ConditionValues->Condition;
            } else {
                $xml_conditions = $xml_data->SiteDefaults->ConditionValues->Condition;
            }
            if ($xml_conditions) {
                foreach ($xml_conditions as $xml_condition) {
                    $conditions[] = array('id_ebay_profile' => (int) $id_ebay_profile, 'id_category_ref' => (int) $category_id, 'id_condition_ref' => (int) $xml_condition->ID, 'name' => pSQL((string) $xml_condition->DisplayName));
                }
            }
            //
            Db::getInstance()->ExecuteS("SELECT 1");
        }
        if ($conditions) {
            $db = Db::getInstance();
            $db->Execute('DELETE FROM ' . _DB_PREFIX_ . 'ebay_category_condition 
				WHERE `id_ebay_profile` = ' . (int) $id_ebay_profile);
            if (version_compare(_PS_VERSION_, '1.5', '>')) {
                $db->insert('ebay_category_condition', $conditions);
            } else {
                foreach ($conditions as $condition) {
                    $db->autoExecute(_DB_PREFIX_ . 'ebay_category_condition', $condition, 'INSERT');
                }
            }
            return true;
        }
        return false;
    }
 public static function loadEbayExcludedLocations($id_ebay_profile)
 {
     $ebay_request = new EbayRequest();
     $excluded_locations = $ebay_request->getExcludeShippingLocations();
     foreach ($excluded_locations as &$excluded_location) {
         foreach ($excluded_location as &$field) {
             $field = pSQL($field);
         }
         $excluded_location['excluded'] = 0;
         $excluded_location['id_ebay_profile'] = intval($id_ebay_profile);
     }
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         Db::getInstance()->insert('ebay_shipping_zone_excluded', $excluded_locations);
     } else {
         foreach ($excluded_locations as $location) {
             EbayShippingZoneExcluded::insert($location);
         }
     }
 }
Ejemplo n.º 12
0
    public static function getEbayUrl($ps_url, $ebay_image_name)
    {
        $db = Db::getInstance();
        $ebay_url = $db->getValue('SELECT `ebay_image_url` from `' . _DB_PREFIX_ . 'ebay_product_image`
			WHERE `ps_image_url` = \'' . pSQL($ps_url) . '\'');
        if (!$ebay_url) {
            $ebay_request = new EbayRequest();
            $ebay_url = $ebay_request->uploadSiteHostedPicture($ps_url, $ebay_image_name);
            if (!$ebay_url) {
                return false;
            }
            $data = array('ps_image_url' => pSQL($ps_url), 'ebay_image_url' => pSQL($ebay_url));
            if (version_compare(_PS_VERSION_, '1.5', '>')) {
                $db->insert('ebay_product_image', $data);
            } else {
                foreach ($conditions as $condition) {
                    $db->autoExecute(_DB_PREFIX_ . 'ebay_product_image', $data, 'INSERT');
                }
            }
        }
        return $ebay_url;
    }
Ejemplo n.º 13
0
 public static function getReturnsPolicies()
 {
     // already in the DB
     if (EbayReturnsPolicy::getTotal()) {
         return EbayReturnsPolicy::getAll();
     }
     $ebay_request = new EbayRequest();
     $policiesDetails = $ebay_request->getReturnsPolicies();
     foreach ($policiesDetails['ReturnsAccepted'] as $returns_policy) {
         EbayReturnsPolicy::insert(array_map('pSQL', $returns_policy));
     }
     $ReturnsWithin = array();
     foreach ($policiesDetails['ReturnsWithin'] as $returns_within) {
         $ReturnsWithin[] = array_map('pSQL', $returns_within);
     }
     Configuration::updateValue('EBAY_RETURNS_WITHIN_VALUES', serialize($ReturnsWithin), false, 0, 0);
     $returnsWhoPays = array();
     foreach ($policiesDetails['ReturnsWhoPays'] as $returns_within) {
         $returnsWhoPays[] = array_map('pSQL', $returns_within);
     }
     Configuration::updateValue('EBAY_RETURNS_WHO_PAYS_VALUES', serialize($returnsWhoPays), false, 0, 0);
     return $policiesDetails['ReturnsAccepted'];
 }
Ejemplo n.º 14
0
 public function loadStoreCategories()
 {
     if ($this->getConfiguration('EBAY_PROFILE_STORE_CAT') || !$this->getToken() || $this->getToken() == null) {
         return;
     }
     $ebay_store_categories = EbayStoreCategory::getStoreCategories($this->id);
     if (count($ebay_store_categories['compatible']) == 0) {
         $ebay = new EbayRequest();
         EbayStoreCategory::updateStoreCategoryTable($ebay->getStoreCategories(), $this);
     }
     $this->setConfiguration('EBAY_PROFILE_STORE_CAT', 1);
 }
Ejemplo n.º 15
0
 * 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-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 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__) . '/../ebay.php';
$ebay = new Ebay();
$ebay_request = new EbayRequest();
$session_id = $ebay->login();
header('Location: ' . $ebay_request->getLoginUrl() . '?SignIn&runame=' . $ebay_request->runame . '&SessID=' . $session_id);
exit;
Ejemplo n.º 16
0
 * 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
	ON a.`id_attribute` = pac.`id_attribute`
Ejemplo n.º 17
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-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_once dirname(__FILE__) . '/../../../config/config.inc.php';
include_once dirname(__FILE__) . '/../ebay.php';
$ebay = new Ebay();
if (!Configuration::get('EBAY_SECURITY_TOKEN') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    echo Tools::safeOutput(Tools::getValue('not_logged_str'));
    return;
}
$ebay_request = new EbayRequest();
/* Loading categories */
$category_config_list = array();
$category_config_list_tmp = Db::getInstance()->executeS('SELECT *
	FROM `' . _DB_PREFIX_ . 'ebay_category_configuration`');
foreach ($category_config_list_tmp as $category) {
    $category_config_list[$category['id_category']] = $category;
}
/* Get categories */
$category_list = Db::getInstance()->executeS('SELECT `id_category`, `name`
	FROM `' . _DB_PREFIX_ . 'category_lang`
	WHERE `id_lang` = ' . (int) Tools::getValue('id_lang') . ' ' . (_PS_VERSION_ >= '1.5' ? $ebay->getContext()->shop->addSqlRestrictionOnLang() : ''));
/* GET One Product by category */
$sql = 'SELECT pl.`name`, pl.`description`, p.`id_category_default`
	FROM `' . _DB_PREFIX_ . 'product` p
	LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
Ejemplo n.º 18
0
 public function displayEbayListingsAjax($id_employee = null)
 {
     $ebay = new EbayRequest();
     $employee = new Employee($id_employee);
     $this->context->employee = $employee;
     $link = $this->context->link;
     $id_lang = $this->context->language->id;
     $products_ebay_listings = array();
     $products = EbayProduct::getProductsWithoutBlacklisted($id_lang, $this->ebay_profile->id, false);
     $data = array('id_lang' => $id_lang, 'titleTemplate' => $this->ebay_profile->getConfiguration('EBAY_PRODUCT_TEMPLATE_TITLE'));
     foreach ($products as $p) {
         $data['real_id_product'] = (int) $p['id_product'];
         $data['name'] = $p['name'];
         $data['manufacturer_name'] = $p['manufacturer_name'];
         $data['reference'] = $p['reference'];
         $data['ean13'] = $p['ean13'];
         $reference_ebay = $p['id_product_ref'];
         $product = new Product((int) $p['id_product'], true, $id_lang);
         if ((int) $p['id_attribute'] > 0) {
             // No Multi Sku case so we do multiple products from a multivariation product
             $combinaison = $this->_getAttributeCombinationsById($product, (int) $p['id_attribute'], $id_lang);
             $combinaison = $combinaison[0];
             $data['reference'] = $combinaison['reference'];
             $data['ean13'] = $combinaison['ean13'];
             $variation_specifics = EbaySynchronizer::_getVariationSpecifics($combinaison['id_product'], $combinaison['id_product_attribute'], $id_lang, $this->ebay_profile->ebay_site_id);
             foreach ($variation_specifics as $variation_specific) {
                 $data['name'] .= ' ' . $variation_specific;
             }
             $products_ebay_listings[] = array('id_product' => $combinaison['id_product'] . '-' . $combinaison['id_product_attribute'], 'quantity' => $combinaison['quantity'], 'prestashop_title' => $data['name'], 'ebay_title' => EbayRequest::prepareTitle($data), 'reference_ebay' => $reference_ebay, 'link' => method_exists($link, 'getAdminLink') ? $link->getAdminLink('AdminProducts') . '&id_product=' . (int) $combinaison['id_product'] . '&updateproduct' : $link->getProductLink((int) $combinaison['id_product']), 'link_ebay' => EbayProduct::getEbayUrl($reference_ebay, $ebay->getDev()));
         } else {
             $products_ebay_listings[] = array('id_product' => $data['real_id_product'], 'quantity' => $product->quantity, 'prestashop_title' => $data['name'], 'ebay_title' => EbayRequest::prepareTitle($data), 'reference_ebay' => $reference_ebay, 'link' => method_exists($link, 'getAdminLink') ? $link->getAdminLink('AdminProducts') . '&id_product=' . (int) $data['real_id_product'] . '&updateproduct' : $link->getProductLink((int) $data['real_id_product']), 'link_ebay' => EbayProduct::getEbayUrl($reference_ebay, $ebay->getDev()));
         }
     }
     $this->smarty->assign('products_ebay_listings', $products_ebay_listings);
     echo $this->display(__FILE__, 'views/templates/hook/ebay_listings_ajax.tpl');
 }
Ejemplo n.º 19
0
 * 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
 */
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__) . '/../ebay.php';
$ebay = new Ebay();
$ebay_request = new EbayRequest();
$session_id = $ebay->login();
Tools::redirect($ebay_request->getLoginUrl() . '?SignIn&runame=' . $ebay_request->runame . '&SessID=' . $session_id);
exit;
Ejemplo n.º 20
0
 private function _getAlerts()
 {
     $alerts = array();
     if (!Configuration::get('EBAY_API_TOKEN')) {
         $alerts[] = 'registration';
     }
     if (!ini_get('allow_url_fopen')) {
         $alerts[] = 'allowurlfopen';
     }
     if (!extension_loaded('curl')) {
         $alerts[] = 'curl';
     }
     $ebay = new EbayRequest();
     $user_profile = $ebay->getUserProfile(Configuration::get('EBAY_API_USERNAME'));
     $this->StoreName = $user_profile['StoreName'];
     if ($user_profile['SellerBusinessType'][0] != 'Commercial') {
         $alerts[] = 'SellerBusinessType';
     }
     return $alerts;
 }