I need to select all products, but currently my code is:
$products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10),NULL,NULL,false,true,true /*Random*/, ($nb ? $nb : 10));
How can I reshape this so that the products do not depend on a $category
. Is there a getProducts()
function that is not child of $category
?
Yes, in products class there is a function getProducts, which can get you all the products in your shop. You can call that function as below:
$productObj = new Product();
$products = $productObj -> getProducts($id_lang, 0, 0, 'id_product', 'DESC' );
First argument is your site current id language, second is for start, used for pagination purpose, which we kept 0. Third argument is for limit, which limits the number of products to fetch. We also kept it 0, so that no limit clause is applied. Fourth is for order by , and fifth is order way, which you can keep as you need.
Note: This code is not tested, it is just to give you idea. You will need to adjust the arguments according to your needs and where you use this code.
Thank you