Skip to content

Export Categories Tree #35

@mesnitu

Description

@mesnitu

Would be a nice addiction to add to the categorymeta export the categories "tree". I found this very useful ( at least to be around) to make data validation lists in libre calc or excel: #

Something like:

  // Multi-Lingual Categories, Categories Meta, Categories Descriptions
  if ($ep_dltype == 'categorymeta') {
    
    // names and descriptions require that we loop thru all languages that are turned on in the store
    foreach ($langcode as $key => $lang) {
      $lid = $lang['id'];
      // metaData start
      $sqlMeta = 'SELECT * FROM ' . TABLE_METATAGS_CATEGORIES_DESCRIPTION . ' WHERE categories_id = :categories_id: AND language_id = :language_id: LIMIT 1 ';
      $sqlMeta = $db->bindVars($sqlMeta, ':categories_id:', $row['v_categories_id'], 'integer');
      $sqlMeta = $db->bindVars($sqlMeta, ':language_id:', $lid, 'integer');
      $resultMeta = ep_4_query($sqlMeta) or die(($ep_uses_mysqli ? mysqli_error($db->link) : mysql_error()));
     
      $rowMeta = ($ep_uses_mysqli ? mysqli_fetch_array($resultMeta) : mysql_fetch_array($resultMeta));
     
      $row['v_metatags_title_' . $lid] = $rowMeta['metatags_title'];
      $row['v_metatags_keywords_' . $lid] = $rowMeta['metatags_keywords'];
      $row['v_metatags_description_' . $lid] = $rowMeta['metatags_description'];
      // metaData end
      // for each language, get category description and name
      $sql2 = 'SELECT * FROM ' . TABLE_CATEGORIES_DESCRIPTION . ' WHERE categories_id = :categories_id: AND language_id = :language_id: LIMIT 1 ';
      $sql2 = $db->bindVars($sql2, ':categories_id:', $row['v_categories_id'], 'integer');
      $sql2 = $db->bindVars($sql2, ':language_id:', $lid, 'integer');
      $result2 = ep_4_query($sql2);
      $row2 = ($ep_uses_mysqli ? mysqli_fetch_array($result2) : mysql_fetch_array($result2));
     
      $row['v_categories_name_' . $lid] = $row2['categories_name'];
     
      $row['v_categories_description_' . $lid] = $row2['categories_description'];
      
      //  $display_cat_tree - Some sort of configuration
      $display_cat_tree = true; 
      if ( $display_cat_tree == true) {
      
      // look for parent categories ID  and Name
      $sql_cat_tree = 'SELECT c.parent_id , cd.categories_name as parent_name FROM ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd WHERE c.categories_id = :categories_id: AND cd.categories_id= c.parent_id ORDER BY cd.categories_name';
      $sql_cat_tree = $db->bindVars($sql_cat_tree, ':categories_id:',  $row2['categories_id'], 'integer');
      $result_cat_tree = $db->Execute($sql_cat_tree);

      if ( $result_cat_tree->RecordCount() > 0) {
         // Display the full categorie path. Found this is very usefull for ie. To create a data validation on Excel or Calc 
        $row['v_categories_tree_' . $lid] = $result_cat_tree->fields['parent_name'] . $category_delimiter . $row['v_categories_name_' . $lid];
       
      } else {
          $row['v_categories_tree_' . $lid] = $row['v_categories_name_' . $lid];
      }
      }
      
    } // foreach

    if (EASYPOPULATE_4_CONFIG_EXPORT_URI != '0') {
      $row['v_html_uri'] = zen_catalog_href_link(FILENAME_DEFAULT, zen_get_path($row['v_categories_id']), 'NONSSL');
    }
  } // if ($ep_dltype categorymeta...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions