public function copyShopData($old_id, $tables_import = false, $deleted = false) { // If we duplicate some specific data, automatically duplicate other data linked to the first // E.g. if carriers are duplicated for the shop, duplicate carriers langs too if (!$old_id) { $old_id = Configuration::get('PS_SHOP_DEFAULT'); } if (isset($tables_import['carrier'])) { $tables_import['carrier_tax_rules_group_shop'] = true; $tables_import['carrier_lang'] = true; } $tables_import['category_lang'] = true; if (isset($tables_import['product'])) { $tables_import['product_lang'] = true; } if (isset($tables_import['module'])) { $tables_import['module_currency'] = true; $tables_import['module_country'] = true; $tables_import['module_group'] = true; } if (isset($tables_import['hook_module'])) { $tables_import['hook_module_exceptions'] = true; } if (isset($tables_import['attribute_group'])) { $tables_import['attribute'] = true; } // Browse and duplicate data foreach (Shop::getAssoTables() as $table_name => $row) { if ($tables_import && !isset($tables_import[$table_name])) { continue; } // Special case for stock_available if current shop is in a share stock group if ($table_name == 'stock_available') { $group = new ShopGroup($this->id_shop_group); if ($group->share_stock && $group->haveShops()) { continue; } } $id = 'id_' . $row['type']; if ($row['type'] == 'fk_shop') { $id = 'id_shop'; } else { $table_name .= '_' . $row['type']; } if (!$deleted) { $res = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . $table_name . '` WHERE `' . $id . '` = ' . (int) $old_id); if ($res) { unset($res[$id]); if (isset($row['primary'])) { unset($res[$row['primary']]); } $categories = Tools::getValue('categoryBox'); if ($table_name == 'product_shop' && count($categories) == 1) { unset($res['id_category_default']); $keys = implode('`, `', array_keys($res)); $sql = 'INSERT IGNORE INTO `' . _DB_PREFIX_ . $table_name . '` (`' . $keys . '`, `id_category_default`, ' . $id . ') (SELECT `' . $keys . '`, ' . (int) $categories[0] . ', ' . (int) $this->id . ' FROM ' . _DB_PREFIX_ . $table_name . ' WHERE `' . $id . '` = ' . (int) $old_id . ')'; } else { $keys = implode('`, `', array_keys($res)); $sql = 'INSERT IGNORE INTO `' . _DB_PREFIX_ . $table_name . '` (`' . $keys . '`, ' . $id . ') (SELECT `' . $keys . '`, ' . (int) $this->id . ' FROM ' . _DB_PREFIX_ . $table_name . ' WHERE `' . $id . '` = ' . (int) $old_id . ')'; } Db::getInstance()->execute($sql); } } } // Hook for duplication of shop data $modules_list = Hook::getHookModuleExecList('actionShopDataDuplication'); if (is_array($modules_list) && count($modules_list) > 0) { foreach ($modules_list as $m) { if (!$tables_import || isset($tables_import['Module' . ucfirst($m['module'])])) { Hook::exec('actionShopDataDuplication', array('old_id_shop' => (int) $old_id, 'new_id_shop' => (int) $this->id), $m['id_module']); } } } }
/** * @return int Total of shop groups */ public static function getTotalShopGroup($active = true) { return count(ShopGroup::getShopGroups($active)); }
public function postProcess() { if (Tools::isSubmit('delete' . $this->table) || Tools::isSubmit('status') || Tools::isSubmit('status' . $this->table)) { $object = $this->loadObject(); if (ShopGroup::getTotalShopGroup() == 1) { $this->errors[] = Tools::displayError('You cannot delete or disable the last shop group.'); } elseif ($object->haveShops()) { $this->errors[] = Tools::displayError('You cannot delete or disable a shop group in use.'); } if (count($this->errors)) { return false; } } return parent::postProcess(); }
public function processDuplicate() { if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) { $id_product_old = $product->id; if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) { $shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID()); foreach ($shops as $shop) { if ($product->isAssociatedToShop($shop['id_shop'])) { $product_price = new Product($id_product_old, false, null, $shop['id_shop']); $product->price = $product_price->price; } } } unset($product->id); unset($product->id_product); $product->indexed = 0; $product->active = 0; if ($product->add() && Category::duplicateProductCategories($id_product_old, $product->id) && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false && GroupReduction::duplicateReduction($id_product_old, $product->id) && Product::duplicateAccessories($id_product_old, $product->id) && Product::duplicateFeatures($id_product_old, $product->id) && Product::duplicateSpecificPrices($id_product_old, $product->id) && Pack::duplicate($id_product_old, $product->id) && Product::duplicateCustomizationFields($id_product_old, $product->id) && Product::duplicateTags($id_product_old, $product->id) && Product::duplicateDownload($id_product_old, $product->id)) { if ($product->hasAttributes()) { Product::updateDefaultAttribute($product->id); } if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { $this->errors[] = Tools::displayError('An error occurred while copying images.'); } else { Hook::exec('actionProductAdd', array('product' => $product)); if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) { Search::indexation(false, $product->id); } $this->redirect_after = self::$currentIndex . (Tools::getIsset('id_category') ? '&id_category=' . (int) Tools::getValue('id_category') : '') . '&conf=19&token=' . $this->token; } } else { $this->errors[] = Tools::displayError('An error occurred while creating an object.'); } } }
public function renderForm() { if (!($obj = $this->loadObject(true))) { return; } $this->fields_form = array('legend' => array('title' => $this->l('Shop'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop name'), 'desc' => array($this->l('This field does not refer to the shop name visible in the front office.'), sprintf($this->l('Follow %sthis link%s to edit the shop name used on the Front Office.'), '<a href="' . $this->context->link->getAdminLink('AdminStores') . '#store_fieldset_general">', '</a>')), 'name' => 'name', 'required' => true))); $display_group_list = true; if ($this->display == 'edit') { $group = new ShopGroup($obj->id_shop_group); if ($group->share_customer || $group->share_order || $group->share_stock) { $display_group_list = false; } } if ($display_group_list) { $options = array(); foreach (ShopGroup::getShopGroups() as $group) { if ($this->display == 'edit' && ($group->share_customer || $group->share_order || $group->share_stock) && ShopGroup::hasDependency($group->id)) { continue; } $options[] = array('id_shop_group' => $group->id, 'name' => $group->name); } if ($this->display == 'add') { $group_desc = $this->l('Warning: You won\'t be able to change the group of this shop if this shop belongs to a group with one of these options activated: Share Customers, Share Quantities or Share Orders.'); } else { $group_desc = $this->l('You can only move your shop to a shop group with all "share" options disabled -- or to a shop group with no customers/orders.'); } $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Shop group'), 'desc' => $group_desc, 'name' => 'id_shop_group', 'options' => array('query' => $options, 'id' => 'id_shop_group', 'name' => 'name')); } else { $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'id_shop_group', 'default' => $group->name); $this->fields_form['input'][] = array('type' => 'textShopGroup', 'label' => $this->l('Shop group'), 'desc' => $this->l('You can\'t edit the shop group because the current shop belongs to a group with the "share" option enabled.'), 'name' => 'id_shop_group', 'value' => $group->name); } $categories = Category::getRootCategories($this->context->language->id); $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Category root'), 'desc' => $this->l('This is the root category of the store that you\'ve created. To define a new root category for your store,') . ' <a href="' . $this->context->link->getAdminLink('AdminCategories') . '&addcategoryroot" target="_blank">' . $this->l('Please click here') . '</a>', 'name' => 'id_category', 'options' => array('query' => $categories, 'id' => 'id_category', 'name' => 'name')); if (Tools::isSubmit('id_shop')) { $shop = new Shop((int) Tools::getValue('id_shop')); $id_root = $shop->id_category; } else { $id_root = $categories[0]['id_category']; } $id_shop = (int) Tools::getValue('id_shop'); self::$currentIndex = self::$currentIndex . '&id_shop_group=' . (int) (Tools::getValue('id_shop_group') ? Tools::getValue('id_shop_group') : (isset($obj->id_shop_group) ? $obj->id_shop_group : Shop::getContextShopGroupID())); $shop = new Shop($id_shop); $selected_cat = Shop::getCategories($id_shop); if (empty($selected_cat)) { // get first category root and preselect all these children $root_categories = Category::getRootCategories(); $root_category = new Category($root_categories[0]['id_category']); $children = $root_category->getAllChildren($this->context->language->id); $selected_cat[] = $root_categories[0]['id_category']; foreach ($children as $child) { $selected_cat[] = $child->id; } } if (Shop::getContext() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop')) { $root_category = new Category($shop->id_category); } else { $root_category = new Category($id_root); } $this->fields_form['input'][] = array('type' => 'categories', 'name' => 'categoryBox', 'label' => $this->l('Associated categories'), 'tree' => array('id' => 'categories-tree', 'selected_categories' => $selected_cat, 'root_category' => $root_category->id, 'use_search' => true, 'use_checkbox' => true), 'desc' => $this->l('By selecting associated categories, you are choosing to share the categories between shops. Once associated between shops, any alteration of this category will impact every shop.')); /*$this->fields_form['input'][] = array( 'type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => true, 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1 ), array( 'id' => 'active_off', 'value' => 0 ) ), 'desc' => $this->l('Enable or disable your store?') );*/ $themes = Theme::getThemes(); if (!isset($obj->id_theme)) { foreach ($themes as $theme) { if (isset($theme->id)) { $id_theme = $theme->id; break; } } } $this->fields_form['input'][] = array('type' => 'theme', 'label' => $this->l('Theme'), 'name' => 'theme', 'values' => $themes); $this->fields_form['submit'] = array('title' => $this->l('Save')); if (Shop::getTotalShops() > 1 && $obj->id) { $disabled = array('active' => false); } else { $disabled = false; } $import_data = array('carrier' => $this->l('Carriers'), 'cms' => $this->l('CMS pages'), 'contact' => $this->l('Contact information'), 'country' => $this->l('Countries'), 'currency' => $this->l('Currencies'), 'discount' => $this->l('Discount prices'), 'employee' => $this->l('Employees'), 'image' => $this->l('Images'), 'lang' => $this->l('Languages'), 'manufacturer' => $this->l('Manufacturers'), 'module' => $this->l('Modules'), 'hook_module' => $this->l('Module hooks'), 'meta_lang' => $this->l('Meta'), 'product' => $this->l('Products'), 'product_attribute' => $this->l('Combinations'), 'scene' => $this->l('Scenes'), 'stock_available' => $this->l('Available quantities for sale'), 'store' => $this->l('Stores'), 'warehouse' => $this->l('Warehouses'), 'webservice_account' => $this->l('Webservice accounts'), 'attribute_group' => $this->l('Attribute groups'), 'feature' => $this->l('Features'), 'group' => $this->l('Customer groups'), 'tax_rules_group' => $this->l('Tax rules groups'), 'supplier' => $this->l('Suppliers'), 'referrer' => $this->l('Referrers/affiliates'), 'zone' => $this->l('Zones'), 'cart_rule' => $this->l('Cart rules')); // Hook for duplication of shop data $modules_list = Hook::getHookModuleExecList('actionShopDataDuplication'); if (is_array($modules_list) && count($modules_list) > 0) { foreach ($modules_list as $m) { $import_data['Module' . ucfirst($m['module'])] = Module::getModuleName($m['module']); } } asort($import_data); if (!$this->object->id) { $this->fields_import_form = array('radio' => array('type' => 'radio', 'label' => $this->l('Import data'), 'name' => 'useImportData', 'value' => 1), 'select' => array('type' => 'select', 'name' => 'importFromShop', 'label' => $this->l('Choose the shop (source)'), 'options' => array('query' => Shop::getShops(false), 'name' => 'name')), 'allcheckbox' => array('type' => 'checkbox', 'label' => $this->l('Choose data to import'), 'values' => $import_data), 'desc' => $this->l('Use this option to associate data (products, modules, etc.) the same way for each selected shop.')); } $this->fields_value = array('id_shop_group' => Tools::getValue('id_shop_group') ? Tools::getValue('id_shop_group') : isset($obj->id_shop_group) ? $obj->id_shop_group : Shop::getContextShopGroupID(), 'id_category' => Tools::getValue('id_category') ? Tools::getValue('id_category') : isset($obj->id_category) ? $obj->id_category : (int) Configuration::get('PS_HOME_CATEGORY'), 'id_theme_checked' => isset($obj->id_theme) ? $obj->id_theme : $id_theme); $ids_category = array(); $shops = Shop::getShops(false); foreach ($shops as $shop) { $ids_category[$shop['id_shop']] = $shop['id_category']; } $this->tpl_form_vars = array('disabled' => $disabled, 'checked' => Tools::getValue('addshop') !== false ? true : false, 'defaultShop' => (int) Configuration::get('PS_SHOP_DEFAULT'), 'ids_category' => $ids_category); if (isset($this->fields_import_form)) { $this->tpl_form_vars = array_merge($this->tpl_form_vars, array('form_import' => $this->fields_import_form)); } return parent::renderForm(); }
protected function supplierImportOne($info, $shop_is_feature_active, $regenerate, $force_ids, $validateOnly = false) { AdminImportController::setDefaultValues($info); if ($force_ids && isset($info['id']) && (int) $info['id']) { $supplier = new Supplier((int) $info['id']); } else { if (array_key_exists('id', $info) && (int) $info['id'] && Supplier::existsInDatabase((int) $info['id'], 'supplier')) { $supplier = new Supplier((int) $info['id']); } else { $supplier = new Supplier(); } } AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supplier); if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $res = false; if ($supplier->id && $supplier->supplierExists($supplier->id)) { $res = $validateOnly || $supplier->update(); } $supplier->force_id = (bool) $force_ids; if (!$res) { $res = $validateOnly || $supplier->add(); } //copying images of suppliers if (!$validateOnly && isset($supplier->image) && !empty($supplier->image)) { if (!AdminImportController::copyImg($supplier->id, null, $supplier->image, 'suppliers', !$regenerate)) { $this->warnings[] = $supplier->image . ' ' . $this->trans('cannot be copied.', array(), 'Admin.Parameters.Notification'); } } if (!$res) { $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID'); } elseif (!$validateOnly) { // Associate supplier to group shop if ($shop_is_feature_active && $supplier->shop) { Db::getInstance()->execute(' DELETE FROM ' . _DB_PREFIX_ . 'supplier_shop WHERE id_supplier = ' . (int) $supplier->id); $supplier->shop = explode($this->multiple_value_separator, $supplier->shop); $shops = array(); foreach ($supplier->shop as $shop) { if (empty($shop)) { continue; } $shop = trim($shop); if (!is_numeric($shop)) { $shop = ShopGroup::getIdByName($shop); } $shops[] = $shop; } $supplier->associateTo($shops); } } } else { $this->errors[] = $this->l('Supplier is invalid') . ' (' . $supplier->name . ')'; $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } }
public function createShop($shop_name) { // Create default group shop $shop_group = new ShopGroup(); $shop_group->name = 'Default'; $shop_group->active = true; if (!$shop_group->add()) { $this->setError($this->language->l('Cannot create group shop') . ' / ' . Db::getInstance()->getMsgError()); return false; } // Create default shop $shop = new Shop(); $shop->active = true; $shop->id_shop_group = $shop_group->id; $shop->id_category = 2; $shop->id_theme = 1; $shop->name = $shop_name; if (!$shop->add()) { $this->setError($this->language->l('Cannot create shop') . ' / ' . Db::getInstance()->getMsgError()); return false; } Context::getContext()->shop = $shop; // Create default shop URL $shop_url = new ShopUrl(); $shop_url->domain = Tools::getHttpHost(); $shop_url->domain_ssl = Tools::getHttpHost(); $shop_url->physical_uri = __PS_BASE_URI__; $shop_url->id_shop = $shop->id; $shop_url->main = true; $shop_url->active = true; if (!$shop_url->add()) { $this->setError($this->language->l('Cannot create shop URL') . ' / ' . Db::getInstance()->getMsgError()); return false; } return true; }
public function supplierImport() { $this->receiveTab(); $handle = $this->openCsvFile(); AdminImportController::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) { if (Tools::getValue('convert')) { $line = $this->utf8EncodeArray($line); } $info = AdminImportController::getMaskedRow($line); AdminImportController::setDefaultValues($info); if (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) { $supplier = new Supplier((int) $info['id']); } else { if (array_key_exists('id', $info) && (int) $info['id'] && Supplier::existsInDatabase((int) $info['id'], 'supplier')) { $supplier = new Supplier((int) $info['id']); } else { $supplier = new Supplier(); } } AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supplier); if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $res = false; if ($supplier->id && $supplier->supplierExists($supplier->id)) { $res = $supplier->update(); } $supplier->force_id = (bool) Tools::getValue('forceIDs'); if (!$res) { $res = $supplier->add(); } //copying images of suppliers if (isset($supplier->image) && !empty($supplier->image)) { if (!AdminImportController::copyImg($supplier->id, null, $supplier->image, 'suppliers', !Tools::getValue('regenerate'))) { $this->warnings[] = $supplier->image . ' ' . Tools::displayError('cannot be copied.'); } } if (!$res) { $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID'); } else { // Associate supplier to group shop if (Shop::isFeatureActive() && $supplier->shop) { Db::getInstance()->execute(' DELETE FROM ' . _DB_PREFIX_ . 'supplier_shop WHERE id_supplier = ' . (int) $supplier->id); $supplier->shop = explode($this->multiple_value_separator, $supplier->shop); $shops = array(); foreach ($supplier->shop as $shop) { if (empty($shop)) { continue; } $shop = trim($shop); if (!is_numeric($shop)) { $shop = ShopGroup::getIdByName($shop); } $shops[] = $shop; } $supplier->associateTo($shops); } } } else { $this->errors[] = $this->l('Supplier is invalid') . ' (' . $supplier->name . ')'; $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } } $this->closeCsvFile($handle); }
Shop::setContext(Shop::CONTEXT_SHOP, $id); echo "-Context is set to " . $type . $id . " "; break; default: Shop::setContext(Shop::CONTEXT_ALL, null); echo "-Context is set to " . $type . " "; } //code v2.4.1 $id_product = (int) Tools::getValue('id_product'); $id_lang = (int) Context::getContext()->language->id; //$product = new Product($id_product, false, $id_lang,$id_shop_source,$context); //version 5.2 - Ne duplique que dans une seule langue $product = new Product($id_product, false, null, $id_shop_source, $context); //version 5.3 All languages //Class product: function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) { $shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID()); foreach ($shops as $shop) { if ($product->isAssociatedToShop($shop['id_shop'])) { $product_price = new Product($id_product_old, false, null, $shop['id_shop']); $product->price = $product_price->price; } } } if (Validate::isLoadedObject($product)) { $id_product_old = $product->id; for ($i = 1; $i <= $quantity; $i++) { echo $i; unset($product->id); unset($product->id_product); $product->indexed = 0; $product->active = 0;
public function postProcess() { if (Tools::isSubmit('delete' . $this->table) || Tools::isSubmit('status') || Tools::isSubmit('status' . $this->table)) { /** @var ShopGroup $object */ $object = $this->loadObject(); if (ShopGroup::getTotalShopGroup() == 1) { $this->errors[] = $this->trans('You cannot delete or disable the last shop group.', array(), 'Admin.Notifications.Error'); } elseif ($object->haveShops()) { $this->errors[] = $this->trans('You cannot delete or disable a shop group in use.', array(), 'Admin.Notifications.Error'); } if (count($this->errors)) { return false; } } return parent::postProcess(); }
public function postProcess() { $id_shops = array(); if (Tools::isSubmit('mass_csv_form_submit')) { if (Shop::getContext() == Shop::CONTEXT_ALL) { $shops = Shop::getShops(); if (!empty($shops)) { foreach ($shops as $s) { $id_shops[] = $s['id_shop']; } } } elseif (Shop::getContext() == Shop::CONTEXT_GROUP) { $shopid = Shop::getContextShopGroupID(true); $shops = ShopGroup::getShopsFromGroup($shopid); if (!empty($shops)) { foreach ($shops as $s) { $id_shops[] = $s['id_shop']; } } } if (empty($id_shops)) { $id_shops[] = Shop::getContextShopID(); } $id_shops = array_unique($id_shops); if (is_uploaded_file($_FILES['csv_file']['tmp_name'])) { $mimes = array('application/vnd.ms-excel', 'text/plain', 'text/csv', 'text/tsv'); if (!in_array($_FILES['csv_file']['type'], $mimes)) { $this->errors[] = Tools::displayError($this->l('Error : Problem with file upload. Please retry or check your file.')); return false; } if (move_uploaded_file($_FILES['csv_file']['tmp_name'], $this->mod->cache_dir . $_FILES['csv_file']['name'])) { $old_file_name = $_FILES['csv_file']['name']; $csv_content = Tools::file_get_contents($this->mod->cache_dir . $old_file_name); $array = $this->csvToArray($csv_content); if (empty($array)) { $this->errors[] = Tools::displayError($this->l('Error : Problem with file upload. Please retry or check your file.')); parent::postProcess(); return false; } foreach ($array as $value) { if (!empty($value[0])) { $new = !empty($value[1]) ? trim($value[1]) : '/'; $type = !empty($value[2]) ? trim($value[2]) : '301'; $regex = !empty($value[3]) ? (int) $value[3] : 0; $redirect = new Redirect(); $redirect->old = trim($value[0]); $redirect->new = $new; $redirect->type = $type; $redirect->regex = (bool) $regex; $redirect->active = true; $redirect->add(); /*foreach ($id_shops as $v) { $db->execute('INSERT INTO `'._DB_PREFIX_.'redirect_shop` (`id_redirect_shop`,`id_redirect`, `id_shop`) VALUES (NULL,'.(int)$redirect->id.','.(int)$v.')'); }*/ } } } Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminRedirect') . '&conf=4'); } } parent::postProcess(); }
public static function create_group($name, $shareCustomers, $shareStock, $shareOrders, $active = true) { if (!Validate::isBool($shareCustomers)) { return false; } if (!Validate::isBool($shareStock)) { return false; } if (!Validate::isBool($shareOrders)) { return false; } if (!Validate::isBool($active)) { return false; } $shopGroup = new ShopGroup(); $shopGroup->name = $name; $shopGroup->active = $active; $shopGroup->share_customer = $shareCustomers; $shopGroup->share_stock = $shareStock; $shopGroup->share_order = $shareOrders; // todo: echo shopgroupid if ($shopGroup->add()) { echo "Shop group {$name} successfully created\n"; return true; } else { echo "Error, could not create shop group {$name}\n"; return false; } }
public function getShopsIds() { $id_shops = array(); if (Shop::getContext() == Shop::CONTEXT_ALL) { $shops = Shop::getShops(); if (!empty($shops)) { foreach ($shops as $s) { $id_shops[] = $s['id_shop']; } } } elseif (Shop::getContext() == Shop::CONTEXT_GROUP) { $shopid = Shop::getContextShopGroupID(true); $shops = ShopGroup::getShopsFromGroup($shopid); if (!empty($shops)) { foreach ($shops as $s) { $id_shops[] = $s['id_shop']; } } } if (empty($id_shops)) { $id_shops[] = Shop::getContextShopID(); } $id_shops = array_unique($id_shops); return $id_shops; }
private function fetchShopGroups() { $groupList = array(); //$groupList[] = array('id' => '0', 'name' => $this->l('Choose your group')); foreach (ShopGroup::getShopGroups(true) as $group) { $groupList[] = array('id' => $group->id, 'name' => $group->name); } $this->context->smarty->assign(array('shop_groups' => $groupList)); }