Name-based URLs Demo

Undefined index: category_tree (1.0.8.16 with Name Based UR - Name-based URLs Demo

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by Omar_one » Sat Jan 07, 2023 12:02 pm

raiwa wrote: in: includes\system\override\name_based_urls.php
at the beginning of the get_category_name method about line 333:

Code: Select all

    Guarantor::ensure_global('category_tree');
so it should be:

Code: Select all

  function get_category_name(&$cID) {
    global $db;

    $full_cPath = $this->get_full_cPath($cID, $single_cID); // full cPath needed for uniformity
    Guarantor::ensure_global('category_tree');
    $cName = ((MODULE_NB_URLS_USE_SEO_TITLES === 'True' && !Text::is_empty($seo_title = $GLOBALS['category_tree']->get($single_cID, 'seo_title')))
thank you so much Rainer,
on the 1st change I just add

Code: Select all

Guarantor::ensure_global('category_tree');
after

Code: Select all

$full_cPath = $this->get_full_cPath($cID, $single_cID);
as the function looking different
here is the whole function

Code: Select all

 function get_category_name(&$cID) {
    global $db;

    $full_cPath = $this->get_full_cPath($cID, $single_cID); // full cPath needed for uniformity
    $cName = ((MODULE_NB_URLS_USE_SEO_TITLES == 'True' && !Text::is_empty($GLOBALS['category_tree']->get($single_cID, 'seo_title')))? $GLOBALS['category_tree']->get($single_cID, 'seo_title') : $GLOBALS['category_tree']->get($single_cID, 'name'));
  $cName = $this->strip($cName);
  $return = $cName;
    $cID = $full_cPath;
    return $return;
  } # end function
Omar_one
VIP Member
VIP Member
Posts: 483
Joined: Fri Oct 25, 2019 5:06 pm
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by raiwa » Sat Jan 07, 2023 12:38 pm

I do not see the difference.
Just put it after this line:

Code: Select all

$full_cPath = $this->get_full_cPath($cID, $single_cID);
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1211
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by Omar_one » Sat Jan 07, 2023 1:15 pm

on this line
here is from your post

Code: Select all

 $cName = ((MODULE_NB_URLS_USE_SEO_TITLES === 'True' && !Text::is_empty($seo_title = $GLOBALS['category_tree']->get($single_cID, 'seo_title')))
and here is from the module

Code: Select all

$cName = ((MODULE_NB_URLS_USE_SEO_TITLES == 'True' && !Text::is_empty($GLOBALS['category_tree']->get($single_cID, 'seo_title')))? $GLOBALS['category_tree']->get($single_cID, 'seo_title') : $GLOBALS['category_tree']->get($single_cID, 'name'));
I have the lite version
Omar_one
VIP Member
VIP Member
Posts: 483
Joined: Fri Oct 25, 2019 5:06 pm
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by Omar_one » Sat Jan 07, 2023 5:41 pm

Thank you Rainer, some of errors not shown ,, but still those ones

Code: Select all

PHP Notice:  Undefined index: path in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 590
PHP Notice:  Undefined index: path in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 626
PHP Notice:  Undefined index: path in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 682
PHP Notice:  Undefined index: path in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 686
PHP Notice:  Undefined index: path in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 716
Omar_one
VIP Member
VIP Member
Posts: 483
Joined: Fri Oct 25, 2019 5:06 pm
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by raiwa » Sat Jan 07, 2023 5:59 pm

I d o not get these in my test-shop and these are only notices.
But you could try changing line 589 and 625 to:

Code: Select all

    if (isset($this->attributes['SEO_REDIRECT']['URI_PARSED']['path']) && strpos($this->attributes['SEO_REDIRECT']['URI_PARSED']['path'], '.html') !== FALSE) {
Then line 681 to:

Code: Select all

      case ( isset($this->uri_parsed['path']) && !is_numeric(strpos(($this->uri), '{')) && strpos($this->uri_parsed['path'], "-p-") !== FALSE ):
And line 684 to:

Code: Select all

      case (  isset($this->uri_parsed['path']) && $this->uri != $this->real_uri && Text::is_empty($this->path_info)):
And line 715 to:

Code: Select all

        } else if ( isset($this->uri_parsed['path']) && ($pStart = strpos($this->uri_parsed['path'], "-c-")) !== FALSE ) {
Please report back
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1211
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by Omar_one » Sat Jan 07, 2023 6:43 pm

thank you Rainer :clap: I just tried to visit the shop different pages and there is no error ,, I will check the error_log file tomorrow when more customer visit the shop and I will let you know if the error appears ,, but till now there is no errors

thank you
Omar
Omar_one
VIP Member
VIP Member
Posts: 483
Joined: Fri Oct 25, 2019 5:06 pm
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by Omar_one » Sat Jan 07, 2023 9:41 pm

Code: Select all

PHP Notice:  Undefined offset: 3 in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 814
PHP Notice:  Undefined offset: 1 in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 834
PHP Notice:  Undefined offset: 1 in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 834
PHP Notice:  Undefined offset: 1 in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 834
PHP Notice:  Undefined offset: 1 in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 834
lines 809 - 821

Code: Select all

  function parse_path($path_info) {
    $tmp = @explode('/', $path_info);
    if ( count($tmp) > 2 ) {
      $container = [];
      for ($i=0, $n=count($tmp); $i<$n; $i++) {
        $container[] = $tmp[$i] . '=' . $tmp[$i+1];
        $i++;
      }
      return @implode('&', $container);
    } else {
      return @implode('=', $tmp);
    }
  } # end function parse_path
lines 828-835

Code: Select all

 function do_redirect() {

    $p = @explode('&', $this->uri_parsed['query']);
    $params =  [];
    foreach( $p as $index => $value ){
      $tmp = @explode('=', $value);
      $params[$tmp[0]] = $tmp[1];
    }
maybe it's need something like this

Code: Select all

$tmp= [];
or

Code: Select all

$tmp= array();
Omar_one
VIP Member
VIP Member
Posts: 483
Joined: Fri Oct 25, 2019 5:06 pm
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by raiwa » Sun Jan 08, 2023 8:26 am

This would fix:
"undefined variable $tmp....."
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1211
Joined: Sat Dec 21, 2019 8:08 am
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by Omar_one » Sun Jan 08, 2023 10:52 am

new PHP Notice

Code: Select all

PHP Notice:  Trying to access array offset on value of type null in /home/XXXX/public_html/includes/system/override/name_based_urls.php on line 367
PHP Notice:  Undefined index: manufacturers_name in /home/XXXX/public_html/includes/classes/manufacturer.php on line 26
PHP Notice:  Undefined index: manufacturers_image in /home/XXXX/public_html/includes/classes/manufacturer.php on line 26
PHP Notice:  Undefined index: manufacturers_description in /home/XXXX/public_html/includes/classes/manufacturer.php on line 26
Lines 353-370

Code: Select all

  function get_manufacturer_name($mID) {

    $sqlCmd = MODULE_NB_URLS_USE_SEO_TITLES == 'True' ? 'IF(md.manufacturers_seo_title != "", md.manufacturers_seo_title, m.manufacturers_name) as mName' : 'm.manufacturers_name as mName';
    $sql = sprintf(<<<'EOSQL'
SELECT %s
  FROM manufacturers m
  LEFT JOIN manufacturers_info md
    ON m.manufacturers_id = md.manufacturers_id
  WHERE m.manufacturers_id = %s
    LIMIT 1
EOSQL
        , $sqlCmd, (int)$mID);

    $result = $GLOBALS['db']->query($sql)->fetch_assoc();
    $mName = $this->strip( $result['mName'] );
    $return = $mName;
    return $return;
  } # end function
 
Omar_one
VIP Member
VIP Member
Posts: 483
Joined: Fri Oct 25, 2019 5:06 pm
Contact:

Re: Undefined index: category_tree (1.0.8.16 with Name Based

by raiwa » Sun Jan 08, 2023 11:08 am

IN line 367 try:

Code: Select all

       $mName = $this->strip( $result['mName']?? '' );
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
PhoenixCart Developer
PhoenixCart Developer
Posts: 1211
Joined: Sat Dec 21, 2019 8:08 am
Contact: