public function importTemplatesForCategory($category_name, $site_code)
 {
     WPLA()->logger->info("importTemplatesForCategory( {$category_name} , {$site_code} )");
     $file_index = WPLA_FeedTemplateIndex::get_file_index();
     $this->imported_count = 0;
     if (!isset($file_index[$site_code])) {
         return;
     }
     $site = $file_index[$site_code];
     // echo "<pre>";print_r($category_name);echo"</pre>";
     // echo "<pre>";print_r($site);echo"</pre>";
     $this->market = WPLA_AmazonMarket::getMarketByCountyCode($site_code);
     $this->site_id = $this->market->id;
     $this->site_code = $site_code;
     if (!isset($site['categories'][$category_name])) {
         return;
     }
     $category = $site['categories'][$category_name];
     // echo "<pre>";print_r($category);echo"</pre>";
     // $template_files = $category['templates'];
     // $btguides_files = $category['btguides'];
     // echo "<pre>";print_r($template_files);echo"</pre>";
     // echo "<pre>";print_r($btguides_files);echo"</pre>";
     WPLA()->logger->info("importing files for {$this->site_id} / {$this->site_code}");
     $this->importTemplates($category['templates'], $site_code);
     $this->importBrowseTreeGuides($category['btguides'], $site_code);
     // remove data files
     $this->cleanupTempFiles();
     return $this->imported_count;
 }
 public function displayCategoriesPage()
 {
     $templates = WPLA_AmazonFeedTemplate::getAll();
     $active_templates = array();
     foreach ($templates as $template) {
         $tpl_name = $template->name == 'Offer' ? 'ListingLoader' : $template->name;
         $active_templates[] = $template->site_id . $tpl_name;
     }
     $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'file_index' => WPLA_FeedTemplateIndex::get_file_index(), 'active_templates' => $active_templates, 'installed_templates' => $templates, 'settings_url' => 'admin.php?page=' . self::ParentMenuId . '-settings', 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-settings' . '&tab=categories');
     $this->display('settings_tpl_btg', $aData);
 }