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); }
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'); }
/** * Parse the data returned by the API and enter them in the table * **/ public static function loadCategorySpecifics($id_ebay_profile) { $request = new EbayRequest($id_ebay_profile); $ebay_category_ids = EbayCategoryConfiguration::getEbayCategoryIds($id_ebay_profile); $ebay_profile = new EbayProfile($id_ebay_profile); foreach ($ebay_category_ids as $ebay_category_id) { $xml_data = $request->GetCategorySpecifics($ebay_category_id); if ($xml_data->Recommendations->NameRecommendation) { foreach ($xml_data->Recommendations->NameRecommendation as $recommendation) { $required = isset($recommendation->ValidationRules->MinValues) && (int) $recommendation->ValidationRules->MinValues >= 1; // if true can be used either in Item Specifics or VariationSpecifics $can_variation = !(isset($recommendation->ValidationRules->VariationSpecifics) && (string) $recommendation->ValidationRules->VariationSpecifics == 'Disabled'); if (isset($recommendation->ValidationRules->SelectionMode)) { if ((string) $recommendation->ValidationRules->SelectionMode == 'Prefilled') { continue; } elseif ((string) $recommendation->ValidationRules->SelectionMode == 'SelectionOnly') { $selection_mode = EbayCategorySpecific::SELECTION_MODE_SELECTION_ONLY; } else { $selection_mode = EbayCategorySpecific::SELECTION_MODE_FREE_TEXT; } } else { $selection_mode = EbayCategorySpecific::SELECTION_MODE_FREE_TEXT; } $values = array(); if (isset($recommendation->ValueRecommendation->Value)) { foreach ($recommendation->ValueRecommendation as $value_recommendation) { $values[] = (string) $value_recommendation->Value; } } $db = Db::getInstance(); $db->execute('INSERT INTO `' . _DB_PREFIX_ . 'ebay_category_specific` (`id_category_ref`, `name`, `required`, `can_variation`, `selection_mode`, `ebay_site_id`) VALUES (' . (int) $ebay_category_id . ', \'' . pSQL((string) $recommendation->Name) . '\', ' . ($required ? 1 : 0) . ', ' . ($can_variation ? 1 : 0) . ', ' . ($selection_mode ? 1 : 0) . ', ' . (int) $ebay_profile->ebay_site_id . ') ON DUPLICATE KEY UPDATE `required` = ' . ($required ? 1 : 0) . ', `can_variation` = ' . ($can_variation ? 1 : 0) . ', `selection_mode` = ' . ($selection_mode ? 1 : 0)); $ebay_category_specific_id = $db->Insert_ID(); if (!$ebay_category_specific_id) { $ebay_category_specific_id = $db->getValue('SELECT `id_ebay_category_specific` FROM `' . _DB_PREFIX_ . 'ebay_category_specific` WHERE `id_category_ref` = ' . (int) $ebay_category_id . ' AND `ebay_site_id` = ' . (int) $ebay_profile->ebay_site_id . ' AND `name` = \'' . pSQL((string) $recommendation->Name) . '\''); } $insert_data = array(); foreach ($values as $value) { $insert_data[] = array('id_ebay_category_specific' => (int) $ebay_category_specific_id, 'value' => pSQL($value)); } EbayCategorySpecificValue::insertIgnore($insert_data); } } } return true; }
/** * * Parse the data returned by the API for the eBay Category Conditions **/ public static function loadCategoryConditions($id_ebay_profile) { $request = new EbayRequest($id_ebay_profile); $ebay_category_ids = EbayCategoryConfiguration::getEbayCategoryIds((int) $id_ebay_profile); $conditions = array(); foreach ($ebay_category_ids as $category_id) { $xml_data = $request->GetCategoryFeatures($category_id); if (isset($xml_data->Category->ConditionEnabled)) { $condition_enabled = $xml_data->Category->ConditionEnabled; } else { $condition_enabled = $xml_data->SiteDefaults->ConditionEnabled; } if (!$condition_enabled) { return; } if (isset($xml_data->Category->ConditionValues->Condition)) { $xml_conditions = $xml_data->Category->ConditionValues->Condition; } else { $xml_conditions = $xml_data->SiteDefaults->ConditionValues->Condition; } if ($xml_conditions) { foreach ($xml_conditions as $xml_condition) { $conditions[] = array('id_ebay_profile' => (int) $id_ebay_profile, 'id_category_ref' => (int) $category_id, 'id_condition_ref' => (int) $xml_condition->ID, 'name' => pSQL((string) $xml_condition->DisplayName)); } } // Db::getInstance()->ExecuteS("SELECT 1"); } if ($conditions) { $db = Db::getInstance(); $db->Execute('DELETE FROM ' . _DB_PREFIX_ . 'ebay_category_condition WHERE `id_ebay_profile` = ' . (int) $id_ebay_profile); if (version_compare(_PS_VERSION_, '1.5', '>')) { $db->insert('ebay_category_condition', $conditions); } else { foreach ($conditions as $condition) { $db->autoExecute(_DB_PREFIX_ . 'ebay_category_condition', $condition, 'INSERT'); } } return true; } return false; }
/** * Called when a product is updated * */ public function hookUpdateProduct($params) { if (!isset($params['product']->id) && !isset($params['id_product'])) { return false; } if (!($id_product = (int) $params['product']->id)) { if (!($id_product = (int) $params['id_product'])) { return false; } } if (!$this->ebay_profile instanceof EbayProfile) { return false; } $sql = array(); $ebay_profiles = eBayProfile::getProfilesByIdShop(); foreach ($ebay_profiles as $profile) { $sql[] = 'SELECT `id_product`, ' . $profile['id_ebay_profile'] . ' AS `id_ebay_profile`, ' . $profile['id_lang'] . ' AS `id_lang` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . $id_product . ' AND `active` = 1 AND `id_category_default` IN (' . EbayCategoryConfiguration::getCategoriesQuery(new EbayProfile($profile['id_ebay_profile'])) . ')'; } foreach ($sql as $q) { if ($products = Db::getInstance()->executeS($q)) { if (Configuration::get('EBAY_SYNC_PRODUCTS_BY_CRON')) { foreach ($products as $product) { EbayProductModified::addProduct($product['id_ebay_profile'], $product['id_product']); } } else { EbaySynchronizer::syncProducts($products, $this->context, $products[0]['id_lang'], 'hookUpdateProduct'); } } } }
private function _getAlertCategories() { $alert = ''; $cat_with_problem = EbayCategoryConfiguration::getMultiVarToNonMultiSku($this->ebay_profile, $this->context); $var = implode(', ', $cat_with_problem); if (count($cat_with_problem) > 0) { if (count($cat_with_problem) == 1) { $alert = $this->ebay->l('You have chosen eBay category : ') . ' "' . $var . '" ' . $this->ebay->l(' which does not support multivariation products. Each variation of a product will generate a new product in eBay'); } else { $alert = $this->ebay->l('You have chosen eBay categories : ') . ' "' . $var . '" ' . $this->ebay->l(' which do not support multivariation products. Each variation of a product will generate a new product in eBay'); } } return $alert; }
private function _postProcessEbaySync() { // Update Sync Option $this->setConfiguration('EBAY_SYNC_OPTION_RESYNC', Tools::getValue('ebay_sync_option_resync') == 1 ? 1 : 0); // Empty error result $this->setConfiguration('EBAY_SYNC_LAST_PRODUCT', 0); if (file_exists(dirname(__FILE__) . '/log/syncError.php')) { @unlink(dirname(__FILE__) . '/log/syncError.php'); } $this->setConfiguration('EBAY_SYNC_MODE', Tools::safeOutput(Tools::getValue('ebay_sync_mode'))); if (Tools::getValue('ebay_sync_products_mode') == 'A') { $this->setConfiguration('EBAY_SYNC_PRODUCTS_MODE', 'A'); } else { $this->setConfiguration('EBAY_SYNC_PRODUCTS_MODE', 'B'); // Select the sync Categories and Retrieve product list for eBay (which have matched and sync categories) if (Tools::getValue('category')) { EbayCategoryConfiguration::updateAll(array('sync' => 0)); foreach (Tools::getValue('category') as $id_category) { EbayCategoryConfiguration::updateByIdCategory($id_category, array('sync' => 1)); } } } }
FROM `' . _DB_PREFIX_ . 'ebay_product` ep2 WHERE ep2.`id_product` = ep.`id_product` AND ep2.`id_ebay_profile` = ep.`id_ebay_profile` )' . ' WHERE 1' . $ebay->addSqlRestrictionOnLang('pl') . $ebay->addSqlRestrictionOnLang('cl') . $ebay->addSqlRestrictionOnLang('s'); if ($search) { $query .= ' AND pl.`name` LIKE \'%' . $search . '%\''; } //$query .= ' GROUP BY s.`id_product`'; $queryCount = preg_replace('/SELECT ([a-zA-Z.,` ]+) FROM /', 'SELECT COUNT(*) FROM ', $query); $nbProducts = Db::getInstance()->getValue($queryCount); $res = Db::getInstance()->executeS($query . ' ORDER BY p.`id_product` ASC LIMIT ' . $offset . ', ' . $limit); // categories $category_list = $ebay->getChildCategories(Category::getCategories($ebay_profile->id_lang, false), version_compare(_PS_VERSION_, '1.5', '>') ? 1 : 0); // eBay categories $ebay_categories = EbayCategoryConfiguration::getEbayCategories($ebay_profile->id); $content = Context::getContext(); $employee = new Employee((int) Tools::getValue('id_employee')); $context->employee = $employee; 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']) {