/** * 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; }
/** * 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; }
$ref_categories[$category['id_category_ref_parent']]['children'][] = $category['id_category_ref']; } } } } foreach ($category_config_list as &$category) { $category['var'] = getSelectors($ref_categories, $category['id_category_ref'], $category['id_category'], $category['level'], $ebay) . '<input type="hidden" name="category[' . (int) $category['id_category'] . ']" value="' . (int) $category['id_ebay_category'] . '" />'; if ($category['percent']) { preg_match('#^([-|+]{0,1})([0-9]{0,3})([\\%]{0,1})$#is', $category['percent'], $temp); $category['percent'] = array('sign' => $temp[1], 'value' => $temp[2], 'type' => $temp[3]); } else { $category['percent'] = array('sign' => '', 'value' => '', 'type' => ''); } } $smarty = Context::getContext()->smarty; $currency = new Currency((int) $ebay_profile->getConfiguration('EBAY_CURRENCY')); /* Smarty datas */ $template_vars = array('tabHelp' => '&id_tab=7', '_path' => $ebay->getPath(), 'categoryList' => $category_list, 'nbCategories' => $nb_categories, 'eBayCategoryList' => $ebay_category_list, 'getNbProducts' => $get_cat_nb_products, 'getNbSyncProducts' => $get_cat_nb_sync_products, 'categoryConfigList' => $category_config_list, 'request_uri' => $_SERVER['REQUEST_URI'], 'noCatSelected' => Tools::getValue('ch_cat_str'), 'noCatFound' => Tools::getValue('ch_no_cat_str'), 'currencySign' => $currency->sign, 'p' => $page); $smarty->assign($template_vars); echo $ebay->display(realpath(dirname(__FILE__) . '/../'), '/views/templates/hook/table_categories.tpl'); /** * Create selectors * * @param array $ref_categories * @param int $id_category_ref * @param int $id_category * @param int $level * @param object $ebay * * @return string */
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'); }
public function hookBackOfficeTop($params) { if (Configuration::get('EBAY_SEND_STATS') && Configuration::get('EBAY_STATS_LAST_UPDATE') < date('Y-m-d\\TH:i:s', strtotime('-1 day')) . '.000Z') { EbayStat::send(); Configuration::updateValue('EBAY_STATS_LAST_UPDATE', date('Y-m-d\\TH:i:s.000\\Z'), false, 0, 0); } // update tracking number of eBay if required if (($id_order = (int) Tools::getValue('id_order')) && ($tracking_number = Tools::getValue('tracking_number')) && ($id_order_ref = EbayOrder::getIdOrderRefByIdOrder($id_order))) { $id_ebay_profiles = Db::getInstance()->ExecuteS('SELECT DISTINCT(`id_ebay_profile`) FROM `' . _DB_PREFIX_ . 'ebay_profile`'); if (count($id_ebay_profiles) == 1) { $order = new Order($id_order); foreach ($id_ebay_profiles as $data) { $id_ebay_profile = (int) $data['id_ebay_profile']; $ebay_profile = new EbayProfile($id_ebay_profile); if (!$ebay_profile->getConfiguration('EBAY_SEND_TRACKING_CODE')) { continue; } $carrier = new Carrier($order->id_carrier, $ebay_profile->id_lang); $ebay_request = new EbayRequest($id_ebay_profile); if ($ebay_request->updateOrderTracking($id_order_ref, $tracking_number, $carrier->name)) { break; } } } } if (!(version_compare(_PS_VERSION_, '1.5.1', '>=') && version_compare(_PS_VERSION_, '1.5.2', '<') && !Shop::isFeatureActive())) { $this->hookHeader($params); } }
foreach ($res as &$row) { if ($row['EbayProductRef']) { $row['link'] = EbayProduct::getEbayUrl($row['EbayProductRef'], $ebay_request->getDev()); } foreach ($category_list as $cat) { if ($cat['id_category'] == $row['id_category']) { $row['category_full_name'] = $cat['name']; $row['is_category_active'] = $cat['active']; break; } } if ($row['id_category_ref']) { foreach ($ebay_categories as $cat) { if ($cat['id'] == $row['id_category_ref']) { $row['ebay_category_full_name'] = $cat['name']; break; } } } if ($ebay_profile->getConfiguration('EBAY_SYNC_PRODUCTS_MODE') == 'A') { $row['sync'] = (bool) $row['id_category_ref']; } // only true if category synced with an eBay category $link = $context->link; $row['link'] = method_exists($link, 'getAdminLink') ? $link->getAdminLink('AdminProducts') . '&id_product=' . (int) $row['id_product'] . '&updateproduct' : $link->getProductLink((int) $row['id_product']); } $smarty = $context->smarty; // Smarty datas $template_vars = array('nbPerPage' => $limit, 'nbProducts' => $nbProducts, 'noProductFound' => Tools::getValue('ch_no_prod_str'), 'p' => $page, 'products' => $res); $smarty->assign($template_vars); echo $ebay->display(realpath(dirname(__FILE__) . '/../'), '/views/templates/hook/table_prestashop_products.tpl');
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); } } $item_specifics = $category->getItemsSpecifics(); $item_specifics_ids = array_map('loadItemsMap', $item_specifics); if (count($item_specifics_ids)) { $sql = 'SELECT `id_ebay_category_specific_value` as id, `id_ebay_category_specific` as specific_id, `value` FROM `' . _DB_PREFIX_ . 'ebay_category_specific_value` WHERE `id_ebay_category_specific` in (' . implode(',', $item_specifics_ids) . ')'; $item_specifics_values = DB::getInstance()->executeS($sql); } else {