luke.lukas Posted May 24, 2022 Share Posted May 24, 2022 Hello, Prestashop version: 1.7.8.5 I've changed /controllers/front/listing/CategoryController.php init() method to $id_category = 123; If I refresh the page it correctly displays the new category. If I put that into a module with: class CategoryController extends CategoryControllerCore { public function init() { $id_category = 123; It won't work, and displays the real id_category, but if I error_log the result and refresh the page it comes back as 123. Thanks Link to comment Share on other sites More sharing options...
luke.lukas Posted May 25, 2022 Author Share Posted May 25, 2022 (edited) 12 hours ago, dnk.hack said: public function init() { $id_category = 123; $this->category = new Category( $id_category, $this->context->language->id ); parent::init(); // !IMPORTANT // over your code perent::init() very important Hello, This is the precise code within the file that doesn't work: <?php class CategoryController extends CategoryControllerCore { public function init() { $id_category = 123; error_log($id_category); $this->category = new Category( $id_category, $this->context->language->id ); parent::init(); if (!Validate::isLoadedObject($this->category) || !$this->category->active) { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); $this->setTemplate('errors/404'); $this->notFound = true; return; } elseif (!$this->category->checkAccess($this->context->customer->id)) { header('HTTP/1.1 403 Forbidden'); header('Status: 403 Forbidden'); $this->errors[] = $this->trans('You do not have access to this category.', [], 'Shop.Notifications.Error'); $this->setTemplate('errors/forbidden'); return; } $categoryVar = $this->getTemplateVarCategory(); $filteredCategory = Hook::exec( 'filterCategoryContent', ['object' => $categoryVar], $id_module = null, $array_return = false, $check_exceptions = true, $use_push = false, $id_shop = null, $chain = true ); if (!empty($filteredCategory['object'])) { $categoryVar = $filteredCategory['object']; } $this->context->smarty->assign([ 'category' => $categoryVar, 'subcategories' => $this->getTemplateVarSubCategories(), ]); } } Note: I just found out that if I put an error_log in the override and the real file, it'll error_log both results back to me, the real file logging 2nd, which I assume is the issue. Edited May 25, 2022 by luke.lukas (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now