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 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; } }