Jump to content

Get all products and properties from Prestashop 1.7


Recommended Posts

Hi,

I'm developing a module, and I need to get all products from my store, include the properties. I saw a resolution here from other version < https://www.prestashop.com/forums/topic/273246-how-to-display-all-product-list-in-my-custome-page-under-my-module-folder/ > but I don't know how can apply to my module without a tpl file, because I don't need show they in the screen. I need include some file? Can you guys help me?

Thaks

Link to comment
Share on other sites

18 hours ago, ndiaga said:

You can read the code of a module like this one : https://prestatuts.com/en/prestashop-modules/40-category-listing.html

 

Thanks. I studied the code a bit, but what I need is something much simpler. Basically I just need to retrieve the data of the products with a Prestashop method to use them later in another API.

And thank you for the quick answer.

Link to comment
Share on other sites

  • 2 weeks later...
On 11/22/2018 at 10:58 AM, ndiaga said:

To get all avalaible products you can use this method:




$all_products=Product::getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category = false,
        $only_active = false, Context $context = null);

 

Sorry for the delay!
Well, I'm a beginner in php and prestahop and I'm not exactly sure how to apply this to the module.would i call this method in the controller or within the module class itself? remembering that I only need to query some specific properties of the products to be used by an external API later.
Thankss

Link to comment
Share on other sites

On 12/3/2018 at 2:18 PM, ndiaga said:

You can call it anywhere this function is  static.

Just use the right parameters for :  


$id_lang, $start, $limit, $order_by, $order_way, $id_category = false,
        $only_active = false, Context $context = null

here is how it should be applied

 


$id_lang=(int)Context::getContext()->language->id;
$start=0;
$limit=100;
$order_by='id_product';
 $order_way='DESC';
$id_category = false; 
$only_active =true;
$context = null;

$all_products=Product::getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category,
        $only_active ,  $context );

 

Thanks!!! It worked for me.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

I write here because I have a similar problem and I hope you can help me:

I need to retrieve in my module the current list of products on a listing page (like category or manufacturer page etc...), I can find it in $params ($params['smarty']->smarty->tpl_vars['listing']->value['result']) but it is a private property and I cannot access it.

How can I get the current products on the page?

Thanks,

Simone

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...