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);
 }
Beispiel #2
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);
 }
    if (array_key_exists($key, $array)) {
        $new = array();
        foreach ($array as $k => $value) {
            $new[$k] = $value;
            if ($k === $key) {
                $new[$new_key] = $new_value;
            }
        }
        return $new;
    }
    return false;
}
$ebay = new Ebay();
$ebay_profile = new EbayProfile((int) Tools::getValue('profile'));
if (!Configuration::get('EBAY_SECURITY_TOKEN') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    return Tools::safeOutput(Tools::getValue('not_logged_str'));
}
$category_list = $ebay->getChildCategories(Category::getCategories(Tools::getValue('id_lang')), version_compare(_PS_VERSION_, '1.5', '>') ? 1 : 0);
$offset = 20;
$page = (int) Tools::getValue('p', 0);
if ($page < 2) {
    $page = 1;
}
$limit = $offset * ($page - 1);
$category_list = array_slice($category_list, $limit, $offset);
$ebay_store_category_list = EbayStoreCategory::getCategoriesWithConfiguration($ebay_profile->id);
$smarty = Context::getContext()->smarty;
/* Smarty datas */
$template_vars = array('tabHelp' => '&id_tab=7', '_path' => $ebay->getPath(), 'categoryList' => $category_list, 'eBayStoreCategoryList' => $ebay_store_category_list, 'request_uri' => $_SERVER['REQUEST_URI'], 'noCatFound' => Tools::getValue('ch_no_cat_str'), 'p' => $page);
$smarty->assign($template_vars);
echo $ebay->display(realpath(dirname(__FILE__) . '/../'), '/views/templates/hook/table_store_categories.tpl');
Beispiel #4
0
 /**
  * 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" />&nbsp;' . $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;
 }
 private static function _writeStoreCategory($category_data, $id_ebay_profile, $ebay_parent_category_id = null)
 {
     $store_category = new EbayStoreCategory();
     $store_category->id_ebay_profile = (int) $id_ebay_profile;
     $store_category->ebay_category_id = pSQL($category_data->CategoryID);
     $store_category->name = (string) $category_data->Name;
     $store_category->order = (int) $category_data->Order;
     if ($ebay_parent_category_id) {
         $store_category->ebay_parent_category_id = $ebay_parent_category_id;
     } else {
         $store_category->ebay_parent_category_id = 0;
     }
     $store_category->save();
     if (isset($category_data->ChildCategory)) {
         foreach ($category_data->ChildCategory as $child_category) {
             EbayStoreCategory::_writeStoreCategory($child_category, $id_ebay_profile, $store_category->ebay_category_id);
         }
     }
 }