0

I have checked log file exc.log

[2020-01-06 11:20:35] main.CRITICAL: Notice: Undefined offset: 2 in /var/www/vhosts/exmp.com/httpdocs/app/design/frontend/Smartwave/porto/Magento_Catalog/templates/category/subcategory.phtml on line 5 {"exception":"[object] (Exception(code: Notice: Undefined offset: 2 in /var/www/vhosts/exmp.com/httpdocs/app/design/frontend/Smartwave/porto/Magento_Catalog//category/subcategory.phtml on line 5 at /var/www/vhosts/exmp.com/httpdocs/vendor/magento/framework/App/ ErrorHandler.php:61)"} []

subcategory.phtml File Code

<?php

$curr_url = $_SERVER['REQUEST_URI'];
$exp_url = explode('/', $curr_url);
//print_r($exp_url);
if($exp_url[2] == 'xyz.html' || $exp_url[2] == 'xyz'){
    $classType='xyz';
    }else if($exp_url[2] == 'abc.html' || $exp_url[2] == 'abc'){ 
        $classType='abc xyz;
        }else{
            $classType='tool-another';
            }
?>

1 Answer 1

2

Please replace your code with below code.

<?php

$curr_url = $_SERVER['REQUEST_URI'];
$exp_url = explode('/', $curr_url);
//print_r($exp_url);

$classType = 'tool-another';
if(!empty($exp_url) && isset($exp_url[2]) )
{
    if($exp_url[2] == 'xyz.html' || $exp_url[2] == 'xyz'){
        $classType = 'xyz';
    } elseif($exp_url[2] == 'abc.html' || $exp_url[2] == 'abc'){ 
       $classType = 'abc xyz';
    }
}

?>

Let me know if you are still getting this issue.

4
  • Did it work for you?
    – DJ Dev
    Jan 6, 2020 at 12:23
  • Its working thankyou
    – DK Thakur
    Jan 6, 2020 at 12:46
  • Please accept this answer if it work for you.
    – DJ Dev
    Jan 6, 2020 at 12:49
  • Please mark this answer as accepted.
    – DJ Dev
    Jan 6, 2020 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.