diseñoPRO Posted April 24, 2018 Share Posted April 24, 2018 (edited) Hi guys, I have a little problem. I need get the products from array of categories. These was saved with a helper tree form. Then, i did this: public function getProducts() { $categories = unserialize(Configuration::get('EXAMPLE_CATEGORIES')); $output = array(); foreach ($categories as $id_category) { $category = new Category($id_category, $this->context->language->id); $products = $category->getProducts($this->context->language->id, 0, 10000); $output = array_merge($output, $products); } return $output; } This works but this return duplicate products, because some products exist in several different categories or parent/child. Have an idea or be better with an sql query? Sorry for my English. Please, help me! Thanks. Edited April 24, 2018 by diseñoPRO ... (see edit history) Link to comment Share on other sites More sharing options...
jgamio Posted April 24, 2018 Share Posted April 24, 2018 You just need to check if the product is on the $output before add it to dont get duplicate products 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