Пример #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);
 }
 function getContent()
 {
     $is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>');
     // Smarty
     $template_vars = array('id_tab' => Tools::getValue('id_tab'), 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'token' => Tools::getValue('token'), 'ebay_token' => Configuration::get('EBAY_SECURITY_TOKEN'), '_module_dir_' => _MODULE_DIR_, 'ebay_categories' => EbayCategoryConfiguration::getEbayCategories($this->ebay_profile->id), 'id_lang' => $this->context->cookie->id_lang, 'id_ebay_profile' => $this->ebay_profile->id, '_path' => $this->path, 'possible_attributes' => AttributeGroup::getAttributesGroups($this->context->cookie->id_lang), 'possible_features' => Feature::getFeatures($this->context->cookie->id_lang, true), 'date' => pSQL(date('Ymdhis')), 'conditions' => $this->_translatePSConditions(EbayCategoryConditionConfiguration::getPSConditions()), 'form_items_specifics' => EbaySynchronizer::getNbSynchronizableEbayCategoryCondition(), 'form_items_specifics_mixed' => EbaySynchronizer::getNbSynchronizableEbayCategoryConditionMixed(), 'isOneDotFive' => $is_one_dot_five);
     return $this->display('formItemsSpecifics.tpl', $template_vars);
 }
Пример #3
0
 private static function _getProductItemSpecifics($ebay_category, $product, $id_lang)
 {
     $item_specifics = $ebay_category->getItemsSpecificValues();
     $item_specifics_pairs = array();
     foreach ($item_specifics as $item_specific) {
         $value = null;
         if ($item_specific['id_feature']) {
             $value = EbaySynchronizer::_getFeatureValue($product->id, $item_specific['id_feature'], $id_lang);
         } elseif ($item_specific['is_brand']) {
             $value = $product->manufacturer_name;
         } else {
             $value = $item_specific['specific_value'];
         }
         if ($value) {
             $item_specifics_pairs[$item_specific['name']] = $value;
         }
     }
     return $item_specifics_pairs;
 }
Пример #4
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');
 }
Пример #5
0
 public function ajaxProductSync()
 {
     $nb_products = EbaySynchronizer::getNbSynchronizableProducts();
     $products = EbaySynchronizer::getProductsToSynchronize(Tools::getValue('option'));
     $nb_products_less = EbaySynchronizer::getNbProductsLess(Tools::getValue('option'), (int) Configuration::get('EBAY_SYNC_LAST_PRODUCT'));
     // Send each product on eBay
     if (count($products)) {
         $this->setConfiguration('EBAY_SYNC_LAST_PRODUCT', (int) $products[0]['id_product']);
         EbaySynchronizer::syncProducts($products, $this->context, $this->ebay_country->getIdLang());
         // we cheat a bit to display a consistent number of products done
         $nb_products_done = min($nb_products - $nb_products_less + 1, $nb_products);
         echo 'KO|<br /><br /> <img src="../modules/ebay/views/img/loading-small.gif" border="0" /> ' . $this->l('Products') . ' : ' . $nb_products_done . ' / ' . $nb_products . '<br /><br />';
     } else {
         echo 'OK|' . $this->displayConfirmation($this->l('Settings updated') . ' (' . $this->l('Option') . ' ' . Configuration::get('EBAY_SYNC_PRODUCTS_MODE') . ' : ' . ($nb_products - $nb_products_less) . ' / ' . $nb_products . ' ' . $this->l('product(s) sync with eBay') . ')');
         if (file_exists(dirname(__FILE__) . '/log/syncError.php')) {
             global $all_error;
             include dirname(__FILE__) . '/log/syncError.php';
             foreach ($all_error as $error) {
                 $products_details = '<br /><u>' . $this->l('Product(s) concerned') . ' :</u>';
                 foreach ($error['products'] as $product) {
                     $products_details .= '<br />- ' . $product;
                 }
                 echo $this->displayError($error['msg'] . '<br />' . $products_details);
             }
             if ($itemConditionError) {
                 //Add a specific message for item condition error
                 $message = $this->l('The item condition value defined in your  configuration is not supported in the eBay category.') . '<br/>';
                 $message .= $this->l('You can modify your item condition in the configuration settings (see supported conditions by categories here: http://pages.ebay.co.uk/help/sell/item-condition.html) ');
                 $message .= $this->l('A later version of the module will allow you to specify item conditions by category');
                 echo $this->displayError($message);
             }
             echo '<style>#content .alert { text-align: left; width: 875px; }</style>';
             @unlink(dirname(__FILE__) . '/log/syncError.php');
         }
     }
 }
Пример #6
0
 public static function prepareTitle($data)
 {
     $product = new Product($data['real_id_product'], false, $data['id_lang']);
     $features = Feature::getFeatures($data['id_lang']);
     $features_product = $product->getFrontFeatures($data['id_lang']);
     $tags = array('{TITLE}', '{BRAND}', '{REFERENCE}', '{EAN}');
     $values = array($data['name'], $data['manufacturer_name'], $data['reference'], $data['ean13']);
     foreach ($features as $feature) {
         $tags[] = trim(str_replace(' ', '_', Tools::strtoupper('{FEATURE_' . $feature['name'] . '}')));
         $hasFeature = array_map(array('EbayRequest', 'getValueOfFeature'), $features_product, $feature);
         if (isset($hasFeature[0]) && $hasFeature[0]) {
             $values[] = $hasFeature[0];
         } else {
             $values[] = '';
         }
     }
     return EbaySynchronizer::fillTemplateTitle($tags, $values, $data['titleTemplate']);
 }