Jump to content

Get Products from Categories (array)


Recommended Posts

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 by diseñoPRO
... (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...