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); }
public static function getInheritedIsMultiSku($id_category_ref, $ebay_site_id) { $row = Db::getInstance()->getRow('SELECT `id_category_ref_parent`, `is_multi_sku` FROM `' . _DB_PREFIX_ . 'ebay_category` WHERE `id_category_ref` = ' . (int) $id_category_ref . ' AND `id_country` = ' . (int) $ebay_site_id); if ($row['is_multi_sku'] !== null) { return $row['is_multi_sku']; } if ((int) $row['id_category_ref_parent'] != (int) $id_category_ref) { return EbayCategory::getInheritedIsMultiSku($row['id_category_ref_parent'], $ebay_site_id); } return $row['is_multi_sku']; }
/** * Main Form Method * */ public function getContent() { if ($this->ebay_profile && !Configuration::get('EBAY_CATEGORY_MULTI_SKU_UPDATE')) { $ebay = new EbayRequest(); EbayCategory::updateCategoryTable($ebay->getCategoriesSkuCompliancy()); } if (Tools::getValue('refresh_store_cat')) { $ebay = new EbayRequest(); EbayStoreCategory::updateStoreCategoryTable($ebay->getStoreCategories(), $this->ebay_profile); } if ($this->ebay_profile) { $this->ebay_profile->loadStoreCategories(); } // Checking Extension if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) { if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) { return $this->html . $this->displayError($this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.')); } elseif (!extension_loaded('curl')) { return $this->html . $this->displayError($this->l('You must enable cURL extension on your server if you want to use this module.')); } elseif (!ini_get('allow_url_fopen')) { return $this->html . $this->displayError($this->l('You must enable allow_url_fopen option on your server if you want to use this module.')); } } // If isset Post Var, post process else display form if (!empty($_POST) && (Tools::isSubmit('submitSave') || Tools::isSubmit('btnSubmitSyncAndPublish') || Tools::isSubmit('btnSubmitSync'))) { $errors = $this->_postValidation(); if (!count($errors)) { $this->_postProcess(); } else { foreach ($errors as $error) { $this->html .= '<div class="alert error"><img src="../modules/ebay/views/img/forbbiden.gif" alt="nok" /> ' . $error . '</div>'; } } if (Configuration::get('EBAY_SEND_STATS')) { $ebay_stat = new EbayStat($this->stats_version, $this->ebay_profile); $ebay_stat->save(); } } $this->html .= $this->_displayForm(); // Set old Context Shop /* RAPH if (version_compare(_PS_VERSION_, '1.5', '>') && Shop::isFeatureActive()) $this->_setContextShop($old_context_shop); */ return $this->html; }
* @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'; 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 {
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; }
private function _getAlertCategories() { $alert = ''; $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'; foreach (Db::getInstance()->ExecuteS($sql_get_cat_non_multi_sku) as $cat) { if ($cat['is_multi_sku'] != 1 && EbayCategory::getInheritedIsMultiSku($cat['id_category_ref']) != 1) { $catProblem = 0; $category = new Category($cat['id_category']); $products = $category->getProductsWs($this->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($this->context->cookie->id_lang) : $product->getAttributeCombinaisons($this->context->cookie->id_lang); if (count($combinations) > 0 && !$catProblem) { $cat_with_problem[] = $cat['name']; $catProblem = 1; } } } } $var = implode(', ', $cat_with_problem); if (count($cat_with_problem) > 0) { if (count($cat_with_problem == 1)) { // RAPH: pb here in the test. Potential typo $alert = '<b>' . $this->l('You have chosen eBay category : ') . $var . $this->l(' which does not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } else { $alert = '<b>' . $this->l('You have chosen eBay categories : ') . $var . $this->l(' which do not support multivariation products. Each variation of a product will generate a new product in eBay') . '</b>'; } } return $alert; }
public static function getInheritedIsMultiSku($id_category_ref) { $row = Db::getInstance()->getRow('SELECT `id_category_ref_parent`, `is_multi_sku` FROM `' . _DB_PREFIX_ . 'ebay_category` WHERE `id_category_ref` = ' . (int) $id_category_ref); if ($row['is_multi_sku'] !== null) { return $row['is_multi_sku']; } if ((int) $row['id_category_ref_parent'] != (int) $id_category_ref) { return EbayCategory::getInheritedIsMultiSku($row['id_category_ref_parent']); } return $row['is_multi_sku']; // RArbuz: shall we not return the category default in this case? }