You are here:  » Category Hierachy Questions


Category Hierachy Questions

Submitted by jens.weber on Sat, 2015-09-19 13:55 in

Hi David,

I am new to Pricetapestry, so appologize for asking probably some stupid questions.

For my site I am using category hierarchies like "category-A"->"category-B"->"category-C" and a mapping like "category-ABC""category-C" where "category-ABC" is part of product metadata.

I am facing now two issues. Hopefully you can help :-)

1st:
When I now walk through the categories from the home-page I end up at search.php with the query "category:category-A/category-B/category-C" and no products show up. When I use the merchant selection from the home site and apply the category filter the products show up.

2nd:
when I do reverse mapping in product hierarchies and map to a category with a "-" in, it doesn´t work. Sometimes it doesn´t save at all or it saves without the "-" in and the mapping doesn´t work. For the normal hierarchy it works smoothly.

Kind regards,
Jens

Submitted by support on Sat, 2015-09-19 14:24

Hello Jens and welcome to the forum!

It does appear to be the same issue and related to the use of the hyphen "-" in category names. Throughout Price Tapestry, where clean, search engine friendly URLs are being generated a "-" is used in place of the SPACE character, so this has actually highlighted a bug in the new category name input when creating a new category within the hierarchy, as the "-" characters should be removed.

I will correct this in the 15/09A beta distribution, in the mean time, if you go to /admin/ > Category Hierarchy Mapping and then use the Rename function to remove the "-" characters from any category names that contain them, and then re-import all feeds that should be all it is.

If you did specifically want to include hyphens in category names, there is in fact a non-breaking hyphen as part of the UTF-8 extended character set that you can use in place of the ASCII hyphen / minus, leaving that to be used in place of the SPACE character - the appearance is identical:

(copy and paste from the above to use easily!)

I would suggest making sure that everything works as expected after removing hyphens from your category names before using the above in their place, but also, as you are using Category Hierarchy Mapping, I would strongly recommend using 15/09A (Beta) which includes a significant re-working of category hierarchy support particularly with regards to large categories...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by jens.weber on Sat, 2015-09-19 14:46

Thanks for the swift reply and apologize for the double posting.

I am old school. I usually use stable versions ;-)
But I´ll give the beta a try and provide you with feedback.

In the meantime I noticed that special characters can also result in an infinity loops in the Responsive HTML Plus (not sure whether it was the hyphen "-" or a dot ".").

Submitted by support on Sat, 2015-09-19 14:55

No worries!

Responsive HTML Plus is included in 15/09A distribution but if you still find the same condition, it's not something I've come across previously if possible if you could let me know an example URL (I'll remove before publishing your reply) or if you're working locally an examplified page URL that causes the infinity loop I'll check that out...

Cheers,
David.
--
PriceTapestry.com

Submitted by jens.weber on Sun, 2015-09-20 07:47

Beta works smoothly!

I also replace the hyphen with another placeholder and menu as well as search works fine.

Submitted by jens.weber on Sun, 2015-09-20 13:59

Hi David,

I installed the beta and it works much better.

Nevertheless the special characters seem to still cause some issues. So the UTF-8 extended characters solves the hyphen issue and I put it into a global filter. Can we put this somehow into a standard filter for future releases?

In addition I noticed now some issues with brackets, ampersand and German umlauts (yes, I try everything possible ;-) ). I use these in the menu for the category hierarchy. The result is that all products are displayed and not only the ones with the correct category. If I do the search via ID everything works as it should.

Please feel free to check my dummy-page: {link saved} for the system behaviour.

Best regards,
Jens

Submitted by support on Mon, 2015-09-21 07:52

Hello Jens,

Thanks for the feedback - I've been able to recreate the problem using the same category names on my test server so I'll check this out and follow up by email...

Cheers,
David.
--
PriceTapestry.com

Submitted by support on Mon, 2015-09-21 09:45

Hello Jens,

All sorted - it was simply down to the noramlisation of the category name as passed into search.php - any ASCII but non alpha-numeric characters that you wish to use in category names (or any other index values throughout the script) can be added to the regular expression used by the tapestry_normalise() function, which can be modified through the $config_normaliseRegExp setting in config.advanced.php. The default value is as follows:

  $config_normaliseRegExp = "A-Za-z0-9".chr(0x80)."-".chr(0xFF)." \.";

...to allow brackets and ampersand, REPLACE with:

  $config_normaliseRegExp = "A-Za-z0-9".chr(0x80)."-".chr(0xFF)." &()\.";

(i've forwarded a modified version of config.advanced.php to you by email for your convenience)

Cheers,
David.
--
PriceTapestry.com

Submitted by Sven on Sat, 2017-04-29 20:13

Hi David,

I also have category hierarchy names with an ampersand and I'd like to see it in the category name all over the site but not in the URL.

For example the category "home & garden" should be normalised to "home-garden" in the URL but only in the URL.

Is that possible?

Best,
Sven

Submitted by support on Mon, 2017-05-01 09:27

Hi all,

To permit characters such as "&" in category hierarchy names whilst keeping search engine friendly URLs with a normalised version of each name; have a go as follows...

Firstly a new normalised_name field needs to be added to the categories hierarchy table - the following dbmod.php script will add the new field, and also populate the field for all existing entries:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."categories_hierarchy`
            ADD `normalised_name` VARCHAR(255) NOT NULL default ''"
;
  
database_queryModify($sql,$result);
  
$sql "CREATE INDEX normalised_name ON `".$config_databaseTablePrefix."categories_hierarchy` (normalised_name)";
  
database_queryModify($sql,$result);
  
$sql "SELECT id,name FROM `".$config_databaseTablePrefix."categories_hierarchy`";
  
database_querySelect($sql,$rows);
  foreach(
$rows as $row)
  {
    
$sql "UPDATE `".$config_databaseTablePrefix."categories_hierarchy`
              SET normalised_name='"
.database_safe(tapestry_normalise($row["name"]))."'
              WHERE id='"
.$row["id"]."'";
    
database_queryModify($sql,$result);
  }
  print 
"Done.";
?>

Next, edit includes/tapestry.php and look for the following code at line 319:

  $href = $config_baseHREF.$indexHREF[$index][$config_useRewrite];

...and REPLACE with:

  $href = $config_baseHREF.$indexHREF[$index][$config_useRewrite];
  if ($index=="category") $entry = tapestry_normalise($entry,"\/");

And then the following code at line 433:

  $sql = "SELECT id,name,parent FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE name='".database_safe($name)."' AND parent='".$currentId."'";

...and REPLACE with:

  $sql = "SELECT id,name,parent FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE normalised_name='".database_safe($name)."' AND parent='".$currentId."'";

Finally, edit admin/categories_hierarchy.php and look for the following code at line 43:

  $sql = "INSERT INTO `".$config_databaseTablePrefix."categories_hierarchy` SET name = '".database_safe($name)."' , parent='".database_safe($id)."'";

...and REPLACE with:

  $sql = "INSERT INTO `".$config_databaseTablePrefix."categories_hierarchy` SET name = '".database_safe($name)."' , normalised_name = '".database_safe(tapestry_normalise($name))."' , parent='".database_safe($id)."'";

And then the following code at line 51:

  $sql = "UPDATE `".$config_databaseTablePrefix."categories_hierarchy` SET name = '".database_safe($name)."' WHERE id = '".database_safe($id)."'";

...and REPLACE with:

  $sql = "UPDATE `".$config_databaseTablePrefix."categories_hierarchy` SET name = '".database_safe($name)."' , normalised_name = '".database_safe(tapestry_normalise($name))."' WHERE id = '".database_safe($id)."'";

Cheers,
David.
--
PriceTapestry.com

Submitted by Sven on Thu, 2017-05-25 18:07

Thank you very much!

Cheers,
Sven