function postProcess() { // Save specifics if (Tools::getValue('specific')) { foreach (Tools::getValue('specific') as $specific_id => $data) { if ($data) { list($data_type, $value) = explode('-', $data); } else { $data_type = null; } $field_names = EbayCategorySpecific::getPrefixToFieldNames(); $data = array_combine(array_values($field_names), array(null, null, null, null)); if ($data_type) { $data[$field_names[$data_type]] = pSQL($value); } if (version_compare(_PS_VERSION_, '1.5', '>')) { Db::getInstance()->update('ebay_category_specific', $data, 'id_ebay_category_specific = ' . (int) $specific_id); } else { Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_category_specific', $data, 'UPDATE', 'id_ebay_category_specific = ' . (int) $specific_id); } } } // save conditions foreach (Tools::getValue('condition') as $category_id => $condition) { foreach ($condition as $type => $condition_ref) { EbayCategoryConditionConfiguration::replace(array('id_ebay_profile' => $this->ebay_profile->id, 'id_condition_ref' => $condition_ref, 'id_category_ref' => $category_id, 'condition_type' => $type)); } } return $this->ebay->displayConfirmation($this->ebay->l('Settings updated')); }
function __construct($stats_version, $ebay_profile) { if (!$ebay_profile) { return; } $this->stats_version = $stats_version; $this->id_ebay_profile = (int) $ebay_profile->id; $this->data = array('id' => sha1($this->_getDefaultShopUrl()), 'profile' => $ebay_profile->id, 'ebay_username' => sha1(Configuration::get('EBAY_IDENTIFIER')), 'ebay_site' => $ebay_profile->ebay_site_id, 'is_multishop' => version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive(), 'install_date' => Configuration::get('EBAY_INSTALL_DATE'), 'nb_listings' => EbayProduct::getNbProducts($ebay_profile->id), 'percent_of_catalog' => EbayProduct::getPercentOfCatalog($ebay_profile), 'nb_prestashop_categories' => EbayCategoryConfiguration::getNbPrestashopCategories($ebay_profile->id), 'nb_ebay_categories' => EbayCategoryConfiguration::getNbEbayCategories($ebay_profile->id), 'nb_optional_item_specifics' => EbayCategorySpecific::getNbOptionalItemSpecifics($ebay_profile->id), 'nb_national_shipping_services' => EbayShipping::getNbNationalShippings($ebay_profile->id), 'nb_international_shipping_services' => EbayShipping::getNbInternationalShippings($ebay_profile->id), 'date_add' => date('Y-m-d H:i:s'), 'Configuration' => EbayConfiguration::getAll($ebay_profile->id, array('EBAY_PAYPAL_EMAIL')), 'return_policy' => $ebay_profile->getReturnsPolicyConfiguration()->ebay_returns_description == '' ? 0 : 1, 'ps_version' => _PS_VERSION_); $this->date_add = date('Y-m-d H:i:s'); }
public static function getItemSpecificsTabConfiguration($id_ebay_profile) { //Check if all mandatory items specifics have been configured $ebay = new Ebay(); if (!EbayCategorySpecific::allMandatorySpecificsAreConfigured($id_ebay_profile)) { return array('indicator' => 'wrong', 'indicatorBig' => 'wrong', 'message' => $ebay->l('You need to configure your mandatory items specifics ', 'ebayvalidatortab')); } //Check if optional items specifics have been configured if (!EbayCategorySpecific::atLeastOneOptionalSpecificIsConfigured($id_ebay_profile)) { return array('indicator' => 'success', 'indicatorBig' => 'mind', 'message' => $ebay->l('You could gain visibility by configuring optional items specifics ', 'ebayvalidatortab')); } return array('indicator' => 'success'); }
*/ 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'); } function loadItemsMap($row) { return $row['id']; } /* Fix for limit db sql request in time */ sleep(1); $category = new EbayCategory((int) Tools::getValue('ebay_category')); if (!Configuration::get('EBAY_SPECIFICS_LAST_UPDATE') || Configuration::get('EBAY_SPECIFICS_LAST_UPDATE') < date('Y-m-d\\TH:i:s', strtotime('-3 days')) . '.000Z') { $res = EbayCategorySpecific::loadCategorySpecifics(); $res &= EbayCategoryCondition::loadCategoryConditions(); if ($res) { Configuration::updateValue('EBAY_SPECIFICS_LAST_UPDATE', date('Y-m-d\\TH:i:s.000\\Z'), false, 0, 0); } } $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 { $item_specifics_values = array(); }
public static function allMandatorySpecificsAreConfigured($id_ebay_profile) { $mandatory_items = EbayCategorySpecific::getAllMandatory($id_ebay_profile); foreach ($mandatory_items as $item) { if (!EbayCategorySpecific::isConfigured($item)) { return false; } } return true; }
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 { $item_specifics_values = array(); }