/**
         * insert shop
         * @param $domain
         * @param $user_id_list
         * @param null $settings
         * @return object
         */
        public function insertShop($domain, $user_id_list, $settings = null) {
            if(!is_array($user_id_list)) $user_id_list = array($user_id_list);

            $oAddonAdminController = getAdminController('addon');
            $oMemberModel = getModel('member');
            $oMemberAdminController = getAdminController('member');
            $oModuleModel = getModel('module');
            $oModuleController = getController('module');

            $oShopModel = getModel('shop');
            $oShopController = getController('shop');
            $oDocumentController = getController('document');
			
            $memberConfig = $oMemberModel->getMemberConfig();
            foreach($memberConfig->signupForm as $item){
            	if($item->isIdentifier) $identifierName = $item->name;
            }
            if($identifierName == "user_id") {
            	$member_srl = $oMemberModel->getMemberSrlByUserID($user_id_list[0]);
            	}
            else {
            	$member_srl = $oMemberModel->getMemberSrlByEmailAddress($user_id_list[0]);
            }
            if(!$member_srl) return new Object(-1,'msg_not_user');

            $member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl);

            if(strpos($domain, '.') !== false) $domain = strtolower($domain);
            $output = $oModuleController->insertSite($domain, 0);
            if(!$output->toBool()) return $output;
            $site_srl = $output->get('site_srl');

            $shop = new stdClass();
            $shop->site_srl = $site_srl;
            $shop->mid = $this->shop_mid;
            $shop->module = 'shop';
            $shop->module_srl = getNextSequence();
            $shop->skin = ($settings->skin) ? $settings->skin : $this->skin;
            $shop->browser_title = ($settings->title) ? $settings->title : sprintf("%s's Shop", $member_info->nick_name);
            $output = $oModuleController->insertModule($shop);

            if(!$output->toBool()) return $output;
            //$module_srl = $output->get('module_srl');
            $module_srl = $shop->module_srl;

            $site = new stdClass();
            $site->site_srl = $site_srl;
            $site->index_module_srl = $module_srl;
			$site->domain = $domain;
            $output = $oModuleController->updateSite($site);

            $output = $oModuleController->insertSiteAdmin($site_srl, $user_id_list);

            //argx for default member group insertion
            $argx = new stdClass();
            $argx->site_srl = $site_srl;
            $argx->title = $domain;
            $argx->is_default = 'Y';
            //$argx->list_order =
            $output = $oMemberAdminController->insertGroup($argx);

            $args = new stdClass();
            $args->shop_title = $shop->browser_title;
            $args->module_srl = $module_srl;
            $args->member_srl = $member_srl;
            $args->timezone = $GLOBALS['_time_zone'];
            $output = executeQuery('shop.insertShop', $args);
            if(!$output->toBool()) return $output;

            $args->comment_editor_skin = 'xpresseditor';
            $args->comment_editor_colorset = 'white';

            $oShopController->updateShopCommentEditor($module_srl, $args->comment_editor_skin, $args->comment_editor_colorset);

            $oAddonAdminController->doInsert('autolink', $site_srl);
            $oAddonAdminController->doInsert('counter', $site_srl);
            $oAddonAdminController->doInsert('member_communication', $site_srl);
            $oAddonAdminController->doInsert('member_extra_info', $site_srl);
            $oAddonAdminController->doInsert('mobile', $site_srl);
            $oAddonAdminController->doInsert('smartphone', $site_srl);
            $oAddonAdminController->doInsert('referer', $site_srl);
            $oAddonAdminController->doInsert('resize_image', $site_srl);
            $oAddonAdminController->doActivate('autolink', $site_srl);
            $oAddonAdminController->doActivate('counter', $site_srl);
            $oAddonAdminController->doActivate('member_communication', $site_srl);
            $oAddonAdminController->doActivate('member_extra_info', $site_srl);
            $oAddonAdminController->doActivate('mobile', $site_srl);
            $oAddonAdminController->doActivate('smartphone', $site_srl);
            $oAddonAdminController->doActivate('referer', $site_srl);
            $oAddonAdminController->doActivate('resize_image', $site_srl);
            $oAddonAdminController->makeCacheFile($site_srl);


            FileHandler::copyDir($this->module_path.'skins/'.$shop->skin, $oShopModel->getShopPath($module_srl));

            foreach($user_id_list as $k => $v){
                $output = $oModuleController->insertAdminId($module_srl, $v);
                if(!$output->toBool()) return $output;
            }

            $langType = Context::getLangType();
            $file = sprintf('%ssample/%s.html',$this->module_path,$langType);
            if(!file_exists(FileHandler::getRealPath($file))){
                $file = sprintf('%ssample/ko.html',$this->module_path);
            }
            $oMemberModel = getModel('member');
            $member_info = $oMemberModel->getMemberInfoByEmailAddress($user_id_list[0]);

            /**
             * Insert default payment method and activate it
             */
            $payment_repository = new PaymentMethodRepository();
            $payment_method = $payment_repository->installPaymentMethod('cash_on_delivery', $module_srl);
            $payment_method->status = 1;
			$payment_method->is_default = 1;
            $payment_repository->updatePaymentMethod($payment_method);

            /**
             * Setup default shipping method
             */
            $shipping_repository = new ShippingMethodRepository();
            $shipping_method = $shipping_repository->installPlugin('flat_rate_shipping', $module_srl);
            $shipping_method->type = 'per_order';
            $shipping_method->price = '10';
            $shipping_method->status = 1;
			$shipping_method->is_default = 1;
            $shipping_repository->updatePlugin($shipping_method);

            /**
             * Set default currency and unit of measure
             */
            $args = new stdClass();
            $args->currency = 'USD';
            $args->currency_symbol = '$';
			$args->unit_of_measure = ShopInfo::UNIT_OF_MEASURE_KGS;
            $args->module_srl = $module_srl;
            $output = executeQuery('shop.updateShopInfo',$args);
            if(!$output->toBool()) return $output;

            /**
             * Create shop menus: header and footer
             */
            // 1. Create menus
            include(_XE_PATH_  . '/modules/shop/libs/model/ShopMenu.php');
            $header_menu_srl = $oShopModel->makeMenu($site_srl, 'Header menu');
            $footer_menu_srl = $oShopModel->makeMenu($site_srl, 'Footer menu');
            $menus = array();
            $menus[ShopMenu::MENU_TYPE_HEADER] = $header_menu_srl;
            $menus[ShopMenu::MENU_TYPE_FOOTER] = $footer_menu_srl;
            $args = new stdClass();
            $args->menus = serialize($menus);
            $args->module_srl = $module_srl;
            $output = executeQuery('shop.updateShopInfo',$args);
            if(!$output->toBool()) return $output;

            // 2. Create pages
            // Header menu
            $oShopModel->insertPage($site_srl, 'about_us', 'About us', array('content' => 'Write a bit about yourself here - let the customers get to know you and your shop'));

            // Footer menu
            $oShopModel->insertPage($site_srl, 'privacy_policy', 'Privacy policy', array('content' => 'Please enter your Privacy policy here'));
            $oShopModel->insertPage($site_srl, 'terms_and_conditions', 'Terms and conditions', array('content' => 'Please enter your Terms and conditions here'));
            $oShopModel->insertPage($site_srl, 'contact_us', 'Contact us', array('content' => 'Write your contact information here'));

            // 3. Add pages to menus
            $oShopModel->insertMenuItem($header_menu_srl, 0, 'about_us', 'About us');
            $oShopModel->insertMenuItem($footer_menu_srl, 0, 'privacy_policy', 'Privacy policy');
            $oShopModel->insertMenuItem($footer_menu_srl, 0, 'terms_and_conditions', 'Terms and conditions');
            $oShopModel->insertMenuItem($footer_menu_srl, 0, 'contact_us', 'Contact us');

            $output = new Object();
            $output->add('module_srl',$module_srl);
            return $output;
        }