Jump to content

How to get SQL query from executed function


onsy

Recommended Posts

I have a function which pulls list of products:

        $start=1000;
        $limit=25;
        $order_by='id_product';
        $order_way='ASC';
        $id_category = false;
        $only_active =true;
        $context = null;

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

How can i see that query? The problem is there are some products missing in this select of 25 products.

 

thanks.

Link to comment
Share on other sites

Hi,

If you just want to display the request, you just have to put this kind of code in the file Product.php

Tools::dieObject($sql);

Also, I would place it right after the $sql declaration to avoid wasting time with all the processing behind it.

Tools::dieObject($sql);
$rq = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if ($order_by == 'price') {
	Tools::orderbyPrice($rq, $order_way);
}

 

Link to comment
Share on other sites

Il y a 4 heures, ps8moduly.cz a dit :

Beware of die(), if you have a live store, customers will wonder if it will show up 😄

Of course, but we can assume that we are in the developer section of the forum and that some evidence is already acquired and if not, that the applicant will acquire it at that time 😉

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