Page 1 of 1

[Solved] Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Thu Jul 18, 2024 3:06 am
by Lumirion
On an Opencart 3.0.3.3 server I keep running into an issue when I use the constant DIR_CATALOG. It keeps throwing:

Code: Select all

Warning: Use of undefined constant DIR_CATALOG - assumed 'DIR_CATALOG' (this will throw an Error in a future version of PHP)
when ever I refer to it. I checked config.php and it is clearly defined. Any one else run into this? This server someone else built. If it helps I also saw this on a version 3.0.3.9 test server I built from scratch.

On my server using DIR_TEMPLATE, instead of DIR_CATALOG, and adjusting relevant paths is a functional work around.

Any one Know why this would be?

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Thu Jul 18, 2024 7:42 am
by nonnedelectari
Lumirion wrote:
Thu Jul 18, 2024 3:06 am
On an Opencart 3.0.3.3 server I keep running into an issue when I use the constant DIR_CATALOG. It keeps throwing:

Code: Select all

Warning: Use of undefined constant DIR_CATALOG - assumed 'DIR_CATALOG' (this will throw an Error in a future version of PHP)
when ever I refer to it. I checked config.php and it is clearly defined. Any one else run into this? This server someone else built. If it helps I also saw this on a version 3.0.3.9 test server I built from scratch.

On my server using DIR_TEMPLATE, instead of DIR_CATALOG, and adjusting relevant paths is a functional work around.

Any one Know why this would be?
Defined in both config.php?

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Thu Jul 18, 2024 5:50 pm
by JNeuhoff
You need to provide some more details for more help here. The DIR_CATALOG is only defined in the admin/config.php, hence it can only be used in the admin controllers, not in frontend controllers.

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Thu Jul 18, 2024 7:12 pm
by paulfeakins
Lumirion wrote:
Thu Jul 18, 2024 3:06 am
Any one Know why this would be?
Perhaps a PHP version change at a guess?

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Fri Jul 19, 2024 12:14 am
by Lumirion
Thank you guys for the tips. @nonnedelectari , I located it in two config.php files though one appears to be a backup. Noted that the DIR_TEMPLATE has a different definition in config.php from the front end version of the define I'm using, as @JNeuhoff explained. I haven't located the file that defines constants that are in scope for front end controllers yet. Any one know where that is?

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Fri Jul 19, 2024 4:24 pm
by JNeuhoff
Lumirion wrote:
Fri Jul 19, 2024 12:14 am
Thank you guys for the tips. @nonnedelectari , I located it in two config.php files though one appears to be a backup. Noted that the DIR_TEMPLATE has a different definition in config.php from the front end version of the define I'm using, as @JNeuhoff explained. I haven't located the file that defines constants that are in scope for front end controllers yet. Any one know where that is?
The frontend config.php file is located in your OpenCart root folder, and it should not have the DIR_CATALOG in there, the latter is only declared in the admin/config.php.

As said, if you need help, then you have to provide some more details.

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Fri Jul 19, 2024 7:39 pm
by nonnedelectari
Lumirion wrote:
Fri Jul 19, 2024 12:14 am
Thank you guys for the tips. @nonnedelectari , I located it in two config.php files though one appears to be a backup. Noted that the DIR_TEMPLATE has a different definition in config.php from the front end version of the define I'm using, as @JNeuhoff explained. I haven't located the file that defines constants that are in scope for front end controllers yet. Any one know where that is?
If you use a constant in admin side, it needs to be defined in the admin config.
if you use a constant in the catalog side, it needs to be defined in the catalog config.
if you use a constant in the system side, it needs to be defined in both.

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Tue Jul 23, 2024 10:06 pm
by Lumirion
Ah! Nice! We don't even have a catalog/config.php. That would explain it. When I get time I'll try and make one.

Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant

Posted: Tue Jul 23, 2024 10:42 pm
by JNeuhoff
Lumirion wrote:
Tue Jul 23, 2024 10:06 pm
Ah! Nice! We don't even have a catalog/config.php. That would explain it. When I get time I'll try and make one.
There is no catalog/config.php in OpenCart!
There is a config.php in the OpenCart root folder, and another one in the admin folder.