Jump to content

How to get all of the products by manufacturer?


Neil Trinh

Recommended Posts

Hi,

I'm trying to get all of the products by manufacture in Prestashop 1.6.1.6.

 

In classes/Manufacturer.php, I found:

 public static function getProducts($id_manufacturer, $id_lang, $p, $n, $order_by = null, $order_way = null,
        $get_total = false, $active = true, $active_category = true, Context $context = null)

And my module:

$products = Manufacturer::getProducts(1,$default_lang, 1, 0, 'id_product');
var_dump($products);

But the result's bool(false)

 

I can get all of the products then compare if product.id_manufacturer == my id_manufacturer but I have 8000 products. So I think get products by manufacturer is the best way. 

Many thanks in advanced!

Edited by Neil Trinh (see edit history)
Link to comment
Share on other sites

It's hard to help without seeing the exact error message. I noticed you have set $n to 0, which means you're asking for 0 products per page. That's probably going to cause an error. It's also possible that $default_lang is empty or has an invalid value.

 

I suggest that you turn on development mode so you can see the MySQL error. To do this, edit config/defines.inc.php and change _PS_DEV_MODE_ from false to true. You should then see an error page with the MySQL query and where the error is.

  • Like 1
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...