You are here:  » Category Hierarchy Import error


Category Hierarchy Import error

Submitted by xlot on Fri, 2015-09-25 15:30 in

Beta 15/9A

Hi David,

Just wanted to give some feedback in hopes to help others that may be having issues with Category Hierarchy. I found that if a category is imported with more than 64 char then it will only insert the first 64 char into the db. This is fine for me however, when you attempt to map that category it may fail to show as a selection on the cat hierarchy reverse page. It is added to the pt_categories_hierarchy DB.

The issue appears to be when importing the feed, if greater than 64 char it cuts all but the first 64 char off, if the last char is whitespace it remains. the data posted to the pt_categories_hierarchy DB is trimmed, so no match is found.

I did a quick workaround in a global filter, but maybe there is a better approach.. maybe adding it to the admin function.

Thanks again for all your support over the years!

  /*************************************************/
  /* trim html */
  /*************************************************/
  $filter_names["HTMLtrim"] = "Trim Whitespace";
  function filter_HTMLtrimConfigure($filter_data)
  {
    print "<p>There are no additional configuration parameters for this filter.</p>";
  }
  function filter_HTMLtrimValidate($filter_data)
  {
  }
  function filter_HTMLtrimExec($filter_data,$text)
  {
    if (strlen($text) > 64){
      $text = substr($text, 0, 64);
    }
    return trim($text);
  }

Submitted by support on Fri, 2015-09-25 16:41

Hi xlot,

No problem - always great to hear from a long time user - 9 years!

I made a significant search performance improvement in the 13/09A distribution (from 2013) but the side effect of this was a reduction in the maximum field size of `category` from 255 to 32 characters - in order that it can be combined as part of the compound indexes.

The actual maximum size depends on the character set and collation of the database but is normally no problem to extend the category field size if required - I am evaluating this as part of the beta as a common side effect of this restriction is being unable to process a verbose category field from a feed e.g. "Category > Sub Category > Sub Category > ...etc." using Explode or other filters.

The following script will re-size the category field on the products table to 150 and enables database debug mode so that if the requested size exceeds the maximum size for the compound index this will be indicated by the error message enabling you to reduce the size if necessary...

<?php
  
require("includes/common.php");
  
$config_databaseDebugMode TRUE;
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            CHANGE `category` `category` VARCHAR(150) NOT NULL default ''"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Cheers,
David.
--
PriceTapestry.com