You are here:  » Best practice: Mapping categories


Best practice: Mapping categories

Submitted by sociallyfamous on Thu, 2015-03-12 22:19 in

Hi.

I have a very large amount of categories from various networks in various formats.

I was wondering what the best practice is to handle such a large amount of categories?

What I am imagining is that you would need all the imported categories in an overview from which you then select in order to be sure to have included each in some parent category.

Like this one could avoid having some ugly unmapped category appearing the the filters.

Right now, I think it is not possible to know if all indexed categories have been mapped.

Only a reimport will provide some guidance which can last 24h with a large set of feeds using the slow import option.

Any solutions on knowing which categories have been mapped already and which once not?

Any tips or best practices would be GREATLY appreciated on this rather never wrecking issue :)

Thanks...

Submitted by support on Fri, 2015-03-13 09:30

Hi,

There's a categoriesunmapped.php script in this thread that might help - one option would be to have that open in a new window whilst working on Category Mapping in another window and then know what to search for in the Category Search form on the Category Mapping configuration page.

Otherwise, with hundreds of feeds from different merchants, you will, inevitably end up with a very large category list. One option that some users implement is to only show your own "master" category names on the main Category A-Z page, which is an easy change. In categories.php look for the following code at line 6:

$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` ORDER BY category";

...and REPLACE with:

$sql = "SELECT DISTINCT(category) as category FROM `".$config_databaseTablePrefix."products` WHERE category IN (SELECT name AS category FROM `".$config_databaseTablePrefix."categories` ) ORDER BY category";

Similarly for PriceTapestry.org for WordPress that I know you're using; look for the following code at line 84:

$sql = "SELECT DISTINCT(".$module.") FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$module." <> '' ORDER BY ".$module;

...and REPLACE with:

if ($module == "category")
{
  $sql = "SELECT DISTINCT(category) FROM `".$pto_config_databaseTablePrefix."products` WHERE category IN (SELECT name AS category FROM `".$pto_config_databaseTablePrefix."categories`) ORDER BY category";
}
else
{
  $sql = "SELECT DISTINCT(".$module.") FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$module." <> '' ORDER BY ".$module;
}

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sociallyfamous on Fri, 2015-03-13 12:36

Hi David,

My biggest worry is actually the filter that I display above the search results.

Would this "is to only show your own "master" category names on the main Category A-Z page" also apply to the filter selection?

This would be a neat solution for now.

Submitted by support on Fri, 2015-03-13 12:47

Hi,

That's no problem - in html/searchfilters.php look for the following code at line 67:

$sql1 = "SELECT DISTINCT(category) FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." AND category <> '' ORDER BY category";

...and REPLACE with:

$sql1 = "SELECT DISTINCT(category) FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." AND category IN (SELECT name AS category FROM `".$config_databaseTablePrefix."categories`) ORDER BY category";

Equivalent modification for PriceTapestry.org for WordPress; in pto_search.php look for the following code at line 867:

$sql = "SELECT DISTINCT(category) FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$pto_searchWhere." AND category <> '' ORDER BY category";

...and REPLACE with:

$sql = "SELECT DISTINCT(category) FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$pto_searchWhere." AND category IN (SELECT name AS category FROM `".$pto_config_databaseTablePrefix."categories`) ORDER BY category";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sociallyfamous on Fri, 2015-03-13 13:05

OK. I think this works. I have re-import a few categories now but the drop-down has now disappeared so it seems to work out fine.

Aweseome. Thanks!

Submitted by sociallyfamous on Tue, 2015-03-24 08:08

Hi David,

Showing master categories in the filter drop-downs works out quite nicely.

I wanted to check with you regarding a possible improvement of category mapping tool.

1. Searching for a keyword inside the help tool for category mapping is limited to 6 entries it seems.

I dont think there should be a limitation as then I have to search for another keyword to capture the remaining unmapped categories that I could have captured with the first keyword search as it keeps on returning the already mapped categories.

2. Alternatively the suggestions in the mapping tool should check for already saved selections on the left in order to avoid adding the same categories again and again. This would resolve the issue number 1 as I could search for the same keyword, save and search again, until I have got them all

Would love to hear your thoughts on this.

Many thanks

Submitted by support on Tue, 2015-03-24 09:22

Hi,

It's no problem to unlimit the search results returned by the helper tool (a single script that powers the product / category / brand search within the various admin tools). If admin/helper.php look for the following code at line 20:

$sql = "SELECT DISTINCT(".$field.") FROM `".$config_databaseTablePrefix."products` WHERE ".$field." LIKE '%".database_safe($q)."%' ORDER BY ".$field." LIMIT 6";

...and REPLACE with:

$sql = "SELECT DISTINCT(".$field.") FROM `".$config_databaseTablePrefix."products` WHERE ".$field." LIKE '%".database_safe($q)."%' ORDER BY ".$field;

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sociallyfamous on Tue, 2015-03-24 09:57

Yes! Thanks.