Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Categories Tree #35

Open
mesnitu opened this issue Feb 23, 2018 · 3 comments
Open

Export Categories Tree #35

mesnitu opened this issue Feb 23, 2018 · 3 comments

Comments

@mesnitu
Copy link

mesnitu commented Feb 23, 2018

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...
@mc12345678
Copy link
Collaborator

Referring to providing a similar export "field" as when exporting the full product information and having the category relationship shown to get to that category? Ie. Tires^Trucks^Manufacturer^Etc?

I could see that being added, though at this time would still consider it as information only and not to directly have an effect during import on category organization. Concern is the confusion caused by also possibly containing conflicting information and expectation that modifying the contents of the field will have an effect on the database or if it does support modification the number of conflicts that would/could be caused by that information being different than the existing "primary key".

@mesnitu
Copy link
Author

mesnitu commented Feb 23, 2018

Yes, I forgot to mention that. This is useful for export just to create those data validation lists. I can't remember any other functionality to this bit. And creating another file layout just for this it's a waste.
So on import, it would be ignored. Basically it's just another small tool to have around.
With this "categories tree" one can make those data validation lists on calc or excel, that can save a lot of time checking the categories names, etc... ( well, at least for me)

@mc12345678
Copy link
Collaborator

Fyi, this (or similar) was already in the to be released version of EP4 as tracked at https://github.com/mc12345678/Easypopulate-4.0.

In that version the result is to show the category's name as built from the root of the store for both the category and category meta exports. The representation is the same as seen in a full product export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants