You are here:  » Category Hierarchy Mapping

Active Forum Topics


Category Hierarchy Mapping

Submitted by wesse249 on Sun, 2015-08-16 08:37 in

Hello David,

When i enable Category Hierarchy Mapping and only want to show a few categories from a feed on my website the script is importing al the products of that feed. Is it possible to import only the categories which you have selected?

Thanks Jan Roel

Submitted by support on Mon, 2015-08-17 06:51

Hello Jan,

Sure - what you could do very easily is re-purpose Niche Mode to apply to a Category Hierarchy Mapping instead of Product Mapping. Firstly, edit includes/admin.php and look for the following comment at line 449:

  /* niche mode */

...and REPLACE with:

  /* niche mode */
  if (!$importRecord["categoryid"]) return;

Then, to enable, edit config.advanced.php and change line 53 as follows;

  $config_nicheMode = TRUE;

Products will then only be imported if they are mapped into the Category Hierarchy.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Sat, 2015-09-05 06:13

Hello David,

How does it exactly work? Because when i enabel niche mode en then import the feed nothing is imported.

Only when i set niche mode to false and then import everything. Then everything in the feed is imported and the i can with reverse mapping add categories. After that i set nichemode to true and then re-import and everything is okai.

Submitted by support on Sat, 2015-09-05 09:34

Hello Jan,

Niche mode should only be enabled once you have fully mapped a feed's categories into your Category Hierarchy, or at least those categories that you wish to import. With Niche Mode enabled and the above modification in place, any product with a category that is not mapped into your hierarchy will be dropped.

Whenever you wish to return to a feed and add more categories to your site, or you wish to map a new feed, temporarily disable niche mode by changing back to false, re-import the feed, complete your mapping, and then set back to true and finally re-import.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by MikeyC on Sun, 2015-09-06 12:20

Hi David,

In relation to this mod i noticed that if a category has subcategories, there is no way to go to the main category by clicking on the menu, as the clicking is to open up the subcategories menu.
I also noticed that i mapped products to the main category, but they don't show. Only the subcategories show.

Is there a way to open the menu by hovering on the main menu, and click to go to the main category/subcategory ?
Also, is there a way of showing products in a main category, and also show the subcategories within that category ?

Mike

Submitted by support on Mon, 2015-09-07 11:40

Hello Mike,

Sure - first of all, to convert to hover activation of the Category menu, edit html/menu.php and look for the following code at line 1 (15/09A) / 2 (16/10A)

<nav class='top-bar' data-topbar role='navigation'>

...and REPLACE with:

<nav class='top-bar' data-topbar role='navigation' data-options='is_hover: true'>

Then look for the following code at line 23 (15/09A) / 25 (16/10A)

  <li class='has-dropdown show-for-medium-up' onClick='JavaScript:menu_loadCat(0);'>

...and REPLACE with:

  <li class='has-dropdown show-for-medium-up' onMouseOver='JavaScript:menu_loadCat(0);'>

And finally the following code at line 53 (15/09A) / 71 (16/10A)

  $("#menu_cat"+id).load("<?php print $config_baseHREF?>html/menu_categories.php?parent="+id, function() { });

...and REPLACE with:

  $("#menu_cat"+id).load("<?php print $config_baseHREF?>html/menu_categories.php?parent="+id, function() {$(document).foundation('topbar', 'reflow');});

With that in place, use the following code as a complete replacement of html/menu_categories.php

<?php
  
require("../includes/common.php");
  
$pathItems = array();
  function 
dropdown($parent)
  {
    global 
$config_databaseTablePrefix;
    global 
$config_baseHREF;
    global 
$pathItems;
    
$sql2 "SELECT * FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE parent='".$parent."'";
    if (
database_querySelect($sql2,$rows2))
    {
      foreach(
$rows2 as $category)
      {
        
$sql3 "SELECT id FROM `".$config_databaseTablePrefix."categories_hierarchy`
                       WHERE parent='"
.$category["id"]."' LIMIT 1";
        if (
database_querySelect($sql3,$rows3))
        {
          
array_push($pathItems,$category["name"]);
          print 
"<li class='has-dropdown'>";
          
$itemHREF $config_baseHREF."search.php?q=category:".tapestry_hyphenate(implode("/",$pathItems));
          print 
"<a href='".$itemHREF."'>".$category["name"]."</a>";
          print 
"<ul id='menu_cat".$category["id"]."' class='dropdown'>";
          
dropdown($category["id"]);
          print 
"</ul>";
          print 
"</li>";
          
array_pop($pathItems);
        }
        else
        {
          
$categoryHierarchyArray tapestry_categoryHierarchyArray(array($category["id"]));
          
$itemHREF tapestry_indexHREF("category",tapestry_hyphenate($categoryHierarchyArray[$category["id"]]));
          print 
"<li>";
          print 
"<a href='".$itemHREF."'>".$category["name"]."</a>";
          print 
"</li>";
        }
      }
    }
  }
  
dropdown(0);
?>

This version returns the full tree with non-leaf entries linked to search.php with a query of category:Path/To/Category which will return results for all products at that level of the hierarchy and all sub-categories...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com