Carpe_diem Posted August 2 Share Posted August 2 Hi guys, I am currently working on my first project on Prestashop 8. I have installed my custom module that was created for version 1.7. I can insert rows without a problem, but I can't edit rows because the categories. Here is my code that works in version 1.7 but not in version 8. $categories = Category::getCategories($this->context->language->id, true, false, $this->context->shop->id); $filteredCategories = array_filter($categories, function ($category) { return $category['id_category'] != 2; // Exclude the "home" category }); $fields_form = array( array( 'type' => 'categories', 'label' => $this->l('Kategorija'), 'name' => 'id_category', 'tree' => array( 'id' => 'category_tree', 'use_search' => false, 'use_checkbox' => true, 'selected_categories' => !empty($data['id_category']) ? explode(',', $data['id_category']) : [], 'categories' => $filteredCategories, ), 'hidden' => true, ), ), Could someone please help me solve this so it works in version 8. Link to comment Share on other sites More sharing options...
Andrei H Posted August 5 Share Posted August 5 Hello, The following code should return the categories for the current shop: $categories = Category::getCategories($this->context->language->id, true, false, 'AND `id_shop_default` = ' . $this->context->shop->id); Let me know if it returns the expected data for you, please. Link to comment Share on other sites More sharing options...
Knowband Plugins Posted August 8 Share Posted August 8 Hi, In PS 8 and above versions, the fourth param is for Additional SQL clause(s) to filter results. And you have passed shop_id in the param which might not be generating a proper query. So, please try removing that fourth param. $categories = Category::getCategories($this->context->language->id, true, false); Regards 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