You are here:  » Category with sub-categories not showing products?

Active Forum Topics


Category with sub-categories not showing products?

Submitted by magnaromagna on Tue, 2021-01-12 09:12 in

Hi,
I'm using category hierarchy. For example, I have:
wine
wine --> red wines
wine --> white wines

I noticed that if merchants has only category "wine", the virtual page
wine/
show only sub-categories (red wines, white wines, etc.) but not the products under (only) "winee" category. Basically, I see products only if the relative category is the last of the hierarchy.

Can this be modified?

Thank you in advance!

Submitted by support on Wed, 2021-01-13 08:27

Hi,

One option would be to pull in search results for the current level of the hierarchy which would include all products at and below the current level, to try this, edit pto_atoz.php and look for the following code at line 164:

  return $html;

...and REPLACE with:

  if (isset($parent) && $parent)
  {
    global $pto_q;
    $pto_q = "category:".$pto_nodeInfo["path"];
    pto_search_buildWhere();
    $html .= pto_search();
  }
  return $html;

If you'd prefer the results to only come from the exact category and not all sub-categories you could change this behaviour in pto_search.php by looking for the for the following code at line 125:

        $where = "categoryid IN (".$in.")";

...and REPLACE with:

        $where = "categoryid = '".$pto_nodeInfo["id"]."'";

Cheers,
David.
--
PriceTapestry.com

Submitted by magnaromagna on Thu, 2021-01-14 12:23

Work perfect, thanks.

I noticed that title is the same for every main category ("category A-Z") even for last sub categories is correctly what added into /categoryinfo/ID_title.html (your mod discussed here: https://www.pricetapestry.org/node/658 )

How to show /categoryinfo/ID_title.html also for main categories?

Thank you in advance again

Submitted by support on Fri, 2021-01-15 08:30

Hi,

Sure - if you edit pto.php and look for the following code beginning at line 597:

    case "merchant":
    case "category":
    case "brand":
      $titlevar = "pto_html_atoz_".$pto_module;
      $title = $$titlevar;
      $title_override = TRUE;
      break;

...and REPLACE with:

    case "category":
      global $pto_nodeInfo;
      global $pto_config_externalPath;
      if (isset($pto_nodeInfo))
      {
        $filename = $pto_config_externalPath."categoryinfo/".$pto_nodeInfo["id"]."_title.html";
        if (file_exists($filename))
        {
          $title .= file_get_contents($filename);
        }
        else
        {
          $title = $pto_nodeInfo["name"];
        }
      }
      else
      {
        $title = $pto_html_atoz_category;
      }
      $title_override = TRUE;
      break;
    case "merchant":
    case "brand":
      $titlevar = "pto_html_atoz_".$pto_module;
      $title = $$titlevar;
      $title_override = TRUE;
      break;

Cheers,
David.
--
PriceTapestry.com