You are here:  » Categories with few products


Categories with few products

Submitted by macland on Fri, 2017-05-26 19:47 in

As we know categories with few products is potentially bad for SEO, but with the different naming systems in the feeds this happens often, especially for a big site like {link saved} which has around 22.000 indexed category sites.
And in that size manually mapping the categories won't be feasible.

I was thinking if it was possible to do something along these lines (in preferred order) if a category has less than X products.

1: Run a script that maps the categories with few products, but automatically try to guess which categories to choose, until all categories has more than X products

2: Let the product stay in the category but remove the category entirely from the site, with no links in the category A-Z overview or in the sitemap

3: Let the product stay in the category but set the category as no-index until is has more than X products.

I think that the first two options would be best for the site as it would save more of the precious link juice, but I don't know if they can be done technically.

Submitted by support on Tue, 2017-05-30 13:30

Hi,

I'm not really sure about option 1 i'm afraid since it would have the same technical difficulties as automated product mapping - easy for a human, very difficult in software! However, issuing noindex for category results with less than x products would be no problem - to give this a go, edit search.php and look for the following code around line 503:

    $header["title"] = $q;

...and REPLACE with:

    $header["title"] = $q;
    if (($parts[0]=="category") && ($resultCount < 10))
    {
      $header["meta"]["robots"] = "noindex";
    }

That would set a robots noindex meta tag for a category search with less than 10 results...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by macland on Wed, 2017-05-31 10:25

Thank you for your reply, I will implement this.

Can I use the same concept in categories.php so that it would only display categories with more than 10 results? No point in wasting linkjuce linking to noindex sites and the users mainly find products with the searchbar

And also what would the code be for doing the same with the brand results?

And finally thank you very much :-)

Submitted by support on Wed, 2017-05-31 12:59

Hi,

> Can I use the same concept in categories.php so that it would
> only display categories with more than 10 results? No point
> in wasting linkjuce linking to noindex sites and the users
> mainly find products with the searchbar

Sure - Category A-Z can be restricted to categories with at least 10 results (or as required) - edit categories.php and look for the following code at line 70:

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

...and REPLACE with:

  $sql = "SELECT category,COUNT(DISTINCT(name)) as numProducts FROM `".$config_databaseTablePrefix."products` GROUP BY category HAVING numProducts >= 10 ORDER BY category";

Similarly for brands.php, look for the following code at line 6:

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

...and REPLACE with:

  $sql = "SELECT brand,COUNT(DISTINCT(name)) as numProducts FROM `".$config_databaseTablePrefix."products` GROUP BY brand HAVING numProducts >= 10 ORDER BY brand";

> And also what would the code be for doing the same
> with the brand results?

As an alternative the previous replacement to search.php to apply to brand queries also, use:

    $header["title"] = $q;
    if ((($parts[0]=="category")||($parts[0]=="brand")) && ($resultCount < 10))
    {
      $header["meta"]["robots"] = "noindex";
    }

Cheers,
David.
--
PriceTapestry.com