public function getContent() { $id_lang = $this->context->language->id; $languages = $this->context->controller->getLanguages(); $shops = Shop::getShops(true, null, true); $shop_id = $this->context->shop->id; $shop_group_id = Shop::getGroupFromShop($shop_id); $gcategories = Tools::getValue('gcategory') ? array_filter(Tools::getValue('gcategory'), 'strlen') : array(); if (count($shops) > 1 && !isset($shop_id)) { $this->_html .= $this->getWarningMultishopHtml(); return $this->_html; } if (Shop::isFeatureActive()) { $this->_html .= $this->getCurrentShopInfoMsg(); } if (Tools::isSubmit('submitFluxOptions')) { $errors_update_shops = array(); $updated = true; $product_type_lang = Tools::getValue('product_type'); foreach ($languages as $k => $lang) { $product_type[$lang['id_lang']] = $product_type_lang[$k]; } $updated &= Configuration::updateValue('GS_PRODUCT_TYPE', $product_type, false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_DESCRIPTION', Tools::getValue('description'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_SHIPPING_PRICE', (double) Tools::getValue('shipping_price'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_SHIPPING_COUNTRY', Tools::getValue('shipping_country'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_IMG_TYPE', Tools::getValue('img_type'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_MPN_TYPE', Tools::getValue('mpn_type'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_GENDER', Tools::getValue('gender'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_AGE_GROUP', Tools::getValue('age_group'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_ATTRIBUTES', Tools::getValue('export_attributes'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_COLOR', implode(';', Tools::getValue('color')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_MATERIAL', implode(';', Tools::getValue('material')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_PATTERN', implode(';', Tools::getValue('pattern')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_SIZE', implode(';', Tools::getValue('size')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_EXPORT_MIN_PRICE', (double) Tools::getValue('export_min_price'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_NO_GTIN', (bool) Tools::getValue('no_gtin'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_NO_BRAND', (bool) Tools::getValue('no_brand'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_ID_EXISTS_TAG', (bool) Tools::getValue('id_exists_tag'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_EXPORT_NAP', (bool) Tools::getValue('export_nap'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_QUANTITY', (bool) Tools::getValue('quantity'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_FEATURED_PRODUCTS', (bool) Tools::getValue('featured_products'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_GEN_FILE_IN_ROOT', (bool) Tools::getValue('gen_file_in_root'), false, (int) $shop_group_id, (int) $shop_id); if (!$updated) { $shop = new Shop($shop_id); $errors_update_shops[] = $shop->name; } if (!count($errors_update_shops)) { $this->confirm = $this->l('The settings have been updated.'); $this->generateXMLFiles(0, $shop_id, $shop_group_id); } else { $this->_html .= $this->displayError(sprintf($this->l('Unable to update settings for the following shop: %s'), implode(', ', $errors_update_shops))); } } elseif (Tools::isSubmit('updateCategory')) { $id_gcategory = (int) Tools::getValue('id_gcategory', 0); $export = (int) Tools::getValue('export', 0); $condition = Tools::getValue('condition'); $availability = Tools::getValue('availability'); $gender = Tools::getValue('gender'); $age_group = Tools::getValue('age_group'); $color = implode(";", Tools::getValue('color')); $material = implode(";", Tools::getValue('material')); $pattern = implode(";", Tools::getValue('pattern')); $size = implode(";", Tools::getValue('size')); $id_shop = (int) Shop::getContextShopID(); if (Tools::isSubmit('updatecateg')) { $gcateg = array(); foreach (Language::getLanguages(false) as $lang) { $gcateg[$lang['id_lang']] = Tools::getValue('gcategory_' . (int) $lang['id_lang']); } GCategories::update($id_gcategory, $gcateg, $export, $condition, $availability, $gender, $age_group, $color, $material, $pattern, $size, $id_shop); $this->confirm = $this->l('Google category has been updated.'); } $this->generateXMLFiles(0, $shop_id, $shop_group_id); } elseif (Tools::isSubmit('updateLanguage')) { $id_glang = (int) Tools::getValue('id_glang', 0); $currencies = implode(";", Tools::getValue('currencies')); $tax_included = (int) Tools::getValue('tax_included', 0); $export = (int) Tools::getValue('active', 0); if (Tools::isSubmit('updatelang')) { GLangAndCurrency::update($id_glang, $currencies, $tax_included, (int) Shop::getContextShopID()); if (count(Tools::getValue('currencies')) > 1) { $this->confirm = $this->l('Selected currencies for this language have been saved.'); } else { $this->confirm = $this->l('Selected currency for this language has been saved.'); } } if ($export) { $this->generateXMLFiles($id_glang, $shop_id, $shop_group_id); } else { $this->_html .= $this->displayConfirmation(html_entity_decode($this->confirm)); } } $gcategories = GCategories::gets((int) $id_lang, null, (int) $shop_id); if (!count($gcategories)) { return $this->_html; } if ((Tools::getIsset('updategshoppingflux') || Tools::getIsset('statusgshoppingflux')) && !Tools::getValue('updategshoppingflux')) { $this->_html .= $this->renderCategForm(); $this->_html .= $this->renderCategList(); } else { if ((Tools::getIsset('updategshoppingflux_lc') || Tools::getIsset('statusgshoppingflux_lc')) && !Tools::getValue('updategshoppingflux_lc')) { $this->_html .= $this->renderLangForm(); $this->_html .= $this->renderLangList(); } else { $this->_html .= $this->renderForm(); $this->_html .= $this->renderCategList(); $this->_html .= $this->renderLangList(); $this->_html .= $this->renderInfo(); } } return $this->_html; }
public function getContent() { $id_lang = (int) Context::getContext()->language->id; $languages = $this->context->controller->getLanguages(); $default_language = (int) Configuration::get('PS_LANG_DEFAULT'); $shops = Shop::getShops(true, null, true); $shop_id = Shop::getContextShopID(); $shop_group_id = Shop::getGroupFromShop($shop_id); $gcategories = Tools::getValue('gcategory') ? array_filter(Tools::getValue('gcategory'), 'strlen') : array(); if (count($shops) > 1 && !isset($shop_id)) { $this->_html .= $this->getWarningMultishopHtml(); return $this->_html; } if (Shop::isFeatureActive()) { $this->_html .= $this->getCurrentShopInfoMsg(); } if (Tools::isSubmit('submitFluxOptions')) { $errors_update_shops = array(); $updated = true; $product_type_lang = Tools::getValue('product_type'); foreach ($languages as $k => $lang) { $product_type[$lang['id_lang']] = $product_type_lang[$k]; } $updated &= Configuration::updateValue('GS_PRODUCT_TYPE', $product_type, false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_DESCRIPTION', Tools::getValue('description'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_SHIPPING_PRICE', (double) Tools::getValue('shipping_price'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_SHIPPING_COUNTRY', Tools::getValue('shipping_country'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_IMG_TYPE', Tools::getValue('img_type'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_MPN_TYPE', Tools::getValue('mpn_type'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_GENDER', Tools::getValue('gender'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_AGE_GROUP', Tools::getValue('age_group'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_ATTRIBUTES', Tools::getValue('export_attributes'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_COLOR', implode(';', Tools::getValue('color')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_MATERIAL', implode(';', Tools::getValue('material')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_PATTERN', implode(';', Tools::getValue('pattern')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_SIZE', implode(';', Tools::getValue('size')), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_EXPORT_MIN_PRICE', (double) Tools::getValue('export_min_price'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_NO_GTIN', (bool) Tools::getValue('no_gtin'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_NO_BRAND', (bool) Tools::getValue('no_brand'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_ID_EXISTS_TAG', (bool) Tools::getValue('id_exists_tag'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_EXPORT_NAP', (bool) Tools::getValue('export_nap'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_QUANTITY', (bool) Tools::getValue('quantity'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_FEATURED_PRODUCTS', (bool) Tools::getValue('featured_products'), false, (int) $shop_group_id, (int) $shop_id); $updated &= Configuration::updateValue('GS_GEN_FILE_IN_ROOT', (bool) Tools::getValue('gen_file_in_root'), false, (int) $shop_group_id, (int) $shop_id); if (!$updated) { $shop = new Shop($shop_id); $errors_update_shops[] = $shop->name; } $count = $this->generateShopFileList((int) $shop_id); // Get active langs on shop $languages = Language::getLanguages(); $confirm = ''; if (!count($errors_update_shops)) { $confirm = $this->l('The settings have been updated.'); foreach ($languages as $i => $lang) { if (Configuration::get('GS_GEN_FILE_IN_ROOT', 0, $shop_group_id, $shop_id) == 1) { $get_file_url = $this->uri . $this->_getOutputFileName($lang['iso_code'], $shop_id); } else { $get_file_url = $this->uri . 'modules/' . $this->getName() . '/file_exports/' . $this->_getOutputFileName($lang['iso_code'], $shop_id); } $confirm .= '<br /> <a href="' . $get_file_url . '" target="_blank">' . $get_file_url . '</a> : ' . ($count[$i]['nb_products'] - $count[$i]['nb_combinations']) . ' ' . $this->l('products exported'); if ($count[$i]['nb_combinations'] > 0) { $confirm .= ': ' . $count[$i]['nb_prod_w_attr'] . ' ' . $this->l('products with attributes'); $confirm .= ', ' . $count[$i]['nb_combinations'] . ' ' . $this->l('attributes combinations'); $confirm .= '.<br/> ' . $this->l('Total') . ': ' . $count[$i]['nb_products'] . ' ' . $this->l('exported products'); if ($count[$i]['non_exported_products'] > 0) { $confirm .= ', ' . $this->l('and') . ' ' . $count[$i]['non_exported_products'] . ' ' . $this->l('not-exported products (non-available)'); } $confirm .= '.'; } else { $confirm .= '.'; } } $this->_html .= $this->displayConfirmation(html_entity_decode($confirm)); } else { $this->_html .= $this->displayError(sprintf($this->l('Unable to update settings for the following shop: %s'), implode(', ', $errors_update_shops))); } } elseif (Tools::isSubmit('updateCategory')) { $id_gcategory = (int) Tools::getValue('id_gcategory', 0); $export = (int) Tools::getValue('export_active_on', 0); $condition = Tools::getValue('condition'); $availability = Tools::getValue('availability'); $gender = Tools::getValue('gender'); $age_group = Tools::getValue('age_group'); $color = implode(";", Tools::getValue('color')); $material = implode(";", Tools::getValue('material')); $pattern = implode(";", Tools::getValue('pattern')); $size = implode(";", Tools::getValue('size')); $id_shop = (int) Shop::getContextShopID(); if (Tools::isSubmit('updatecateg')) { $gcateg = array(); foreach (Language::getLanguages(false) as $lang) { $gcateg[$lang['id_lang']] = Tools::getValue('gcategory_' . (int) $lang['id_lang']); } GCategories::update($id_gcategory, $gcateg, $export, $condition, $availability, $gender, $age_group, $color, $material, $pattern, $size, $id_shop); $this->_html .= $this->displayConfirmation($this->l('Google category has been updated.')); } } if ((Tools::getIsset('updategshoppingflux') || Tools::getIsset('statusgshoppingflux')) && !Tools::getValue('updategshoppingflux')) { $this->_html .= $this->renderAddForm(); } $this->_html .= $this->renderForm(); $gcategories = GCategories::gets((int) $id_lang, null, (int) $shop_id); if (!count($gcategories)) { return $this->_html; } $this->_html .= $this->renderList(); $this->_html .= $this->renderInfo(); return $this->_html; }