I have a cronjob that calls a php file at the root folder. The php file grabs the top category and if any categories are empty (all products are disabled) it disables the category. (I won't to hide categories that are empty, that is my goal) I need assistance from the community on trying to figure this out. Listed below is the error (Uncaught Error: Call to undefined method Context::getTopCategory())
PFA: php file
Please assist and thanks.
Prestashop 1.7.8.0 / CPanel / php 7.3 (ea-php73)
Cronjob: 0011*/usr/bin/curl https://mysite.com/update_categories.php (Set at 1 year for now until I can figure this out)
Error:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 259 0 259 0 0 471 0 --:--:-- --:--:-- --:--:-- 471
<br />
<b>Fatal error</b>: Uncaught Error: Call to undefined method Context::getTopCategory() in /home/local/public_html/update_categories.php:7
Stack trace:
#0 {main}
thrown in <b>/home/local/public_html/update_categories.php</b> on line <b>7</b><br />