Box Categories and a Categories menu addon Problem

Open to all! Ask other shopowners for help.
Post Reply
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Box Categories and a Categories menu addon Problem

Post by radhavallabh »

Hi;
I am using the 1.0.8.2 version;
I activated the box categories and get the below error on click
Fatal error
: Uncaught Error: Call to undefined method tree_display::get() in xx/includes/modules/content/header/cm_header_breadcrumb.php:51 Stack trace: #0 xx/includes/system/versioned/1.0.7.9/osc_template.php(106): cm_header_breadcrumb->execute() #1 xx/templates/default/includes/components/header.php(15): oscTemplate->getContent('header') #2 xx/templates/default/includes/components/template_top.php(56): require('/xx...') #3 /xx/templates/default/includes/pages/index.php(12): require('/xx...') #4 /hxx/index.php(36): require('xx...') #5 {main} thrown in
/xxincludes/modules/content/header/cm_header_breadcrumb.php
on line
51
On another Main Category Menu addon I use below code on the cm_header_main_menu.php
It worked well up to 1.0.7.5 but now is giving issues --

I tried upgrading it to current pattern of code but returns nothing just a light grey small box where the menu should appear(No errors at all in backend too)--

Code: Select all

 function execute() {
global $root_category_id, $category_tree, $category_array;

	   $category_tree = new tree_display(Guarantor::ensure_global('category_tree'));
      $category_tree->setMaximumLevel(1);
      $category_array = $category_tree->buildBranchArray($GLOBALS['root_category_id']);

      foreach ($category_array as $Tr => $ee) {
        $category_tree->get_children($ee['id'], $category_array[$Tr]['children']);
      }

      $el = $category_array;

      foreach ($el as $e => $l) {
        if (is_array($l['children'])) {
          foreach ($l['children'] as $s => $t) {
            $el[$e]['children'][$s] = $category_tree->getData($t);
          }
        }
      }


 $tpl_data = ['group' => $this->group, 'file' => __FILE__];
      include 'includes/modules/content/cm_template.php';
    }
Please can someone help me understand the issues due to which this is happening...
Thank you in advance to all for helping me get through with this problem,
Awaiting your valued reply;
Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Box Categories and a Categories menu addon Problem

Post by ecartz »

Change

Code: Select all

global $root_category_id, $category_tree, $category_array;
to

Code: Select all

global $root_category_id, $category_array;
in the block of code that you posted.

Code: Select all

      foreach ($category_array as $Tr => $ee) {
        $category_tree->get_children($ee['id'], $category_array[$Tr]['children']);
      }
That doesn't do anything, so I'd remove it. Or go back to whatever it was originally, because at the moment, I can't see what you want to do.

You could try changing

Code: Select all

      foreach ($el as $e => $l) {
        if (is_array($l['children'])) {
          foreach ($l['children'] as $s => $t) {
            $el[$e]['children'][$s] = $category_tree->getData($t);
          }
        }
      }
to

Code: Select all

      foreach ($el as $e => $l) {
        foreach ($GLOBALS['category_tree']->get_children() ?? [] as $s => $t) {
            $el[$e]['children'][$s] = $GLOBALS['category_tree']->get($s);
        }
      }
That should at least run.
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Re: Box Categories and a Categories menu addon Problem

Post by radhavallabh »

ecartz wrote: Thu May 20, 2021 8:41 pm Change

Code: Select all

global $root_category_id, $category_tree, $category_array;
to

Code: Select all

global $root_category_id, $category_array;
in the block of code that you posted.

Code: Select all

      foreach ($category_array as $Tr => $ee) {
        $category_tree->get_children($ee['id'], $category_array[$Tr]['children']);
      }
That doesn't do anything, so I'd remove it. Or go back to whatever it was originally, because at the moment, I can't see what you want to do.

You could try changing

Code: Select all

      foreach ($el as $e => $l) {
        if (is_array($l['children'])) {
          foreach ($l['children'] as $s => $t) {
            $el[$e]['children'][$s] = $category_tree->getData($t);
          }
        }
      }
to

Code: Select all

      foreach ($el as $e => $l) {
        foreach ($GLOBALS['category_tree']->get_children() ?? [] as $s => $t) {
            $el[$e]['children'][$s] = $GLOBALS['category_tree']->get($s);
        }
      }
That should at least run.
Hi dear Thank you for the valued help;
As you said.. I dug more thinking to get the root of the problem... With my very very little knowledge...

My code was actually not working at all irrespective of changes, After more screening of detail it is the classes that are posing the issue.
I have a customized class file that extends the category_tree class which worked till we had another version of the category class to our system folder.

We have
A system/versioned/1.0.0.0/category_tree.php class (It all worked irrespective of my code till we had the below additions to the folder.)

system/versioned/1.0.7.other/category_tree.php class( It stopped working since this addition)

Can you help me to overcome this issue? On how to solve it...

Thanking you in advance;
Regds./
radhavallabh
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Re: Box Categories and a Categories menu addon Problem

Post by radhavallabh »

ecartz wrote: Thu May 20, 2021 8:41 pm Change

Code: Select all

global $root_category_id, $category_tree, $category_array;
to

Code: Select all

global $root_category_id, $category_array;
in the block of code that you posted.

Code: Select all

      foreach ($category_array as $Tr => $ee) {
        $category_tree->get_children($ee['id'], $category_array[$Tr]['children']);
      }
That doesn't do anything, so I'd remove it. Or go back to whatever it was originally, because at the moment, I can't see what you want to do.

You could try changing

Code: Select all

      foreach ($el as $e => $l) {
        if (is_array($l['children'])) {
          foreach ($l['children'] as $s => $t) {
            $el[$e]['children'][$s] = $category_tree->getData($t);
          }
        }
      }
to

Code: Select all

      foreach ($el as $e => $l) {
        foreach ($GLOBALS['category_tree']->get_children() ?? [] as $s => $t) {
            $el[$e]['children'][$s] = $GLOBALS['category_tree']->get($s);
        }
      }
That should at least run.
Hi dear;
For now I fixed it by getting rid of this code and cloning the version 1.0.0.0 category_tree class with a new name in override and extended my current customized class with it.
But I would be really glad if you could explain the difference in working of the below 2 classes as I am not able to get it working with the new one at all...

system/versioned/1.0.0.0/category_tree.php class (It all worked irrespective of my code till we had the below additions to the folder.)

system/versioned/1.0.7.other/category_tree.php class( It stopped working since this addition)


so in future i could revamp the code in sync of the new class

Thank you again for all the valuable help in advance;
Very Warm Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply