Stack Exchange
Output the value from Search.php query to product-list.tpl in Prestashop
I need to output in product-list.tpl file the result of a query from within classes/Search.php in Prestashop. The query in classes/Search.php is:
        $sql = 'SELECT *
                FROM `'._DB_PREFIX_.'category_group` cg
                INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category`
                INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category`
                INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product`
                INNER JOIN `'._DB_PREFIX_.'product_part_number` ON p. `id_product` = `ID`
                '.Shop::addSqlAssociation('product', 'p', false).'
                WHERE c.`active` = 1
                    AND product_shop.`active` = 1
                    AND product_shop.`visibility` IN ("both", "search")
                    AND product_shop.indexed = 1
                    AND cg.`id_group` '.(!$id_customer ?  '= 1' : 'IN (
                        SELECT id_group FROM '._DB_PREFIX_.'customer_group 
                        WHERE id_customer = '.(int)$id_customer.'

                    )');
        $results = $db->executeS($sql);

This is outputting a series of "GREKA" values in the '._DB_PREFIX_.'product_part_number table at the top of the search results page from the query above:
        $eligible_products = array();

            foreach ($results as $row){
                $eligible_products[] = $row['id_product'];
                echo $row['GREKA'];
            }

What I need it to do is output the "GREKA" value within the tpl file themes/product-list.tpl for that product. This tpl file is using Smarty to output the results of the product search, I need to know how to call the "GREKA" value from the query to the foreach loop. I imagine it would be something like this:
       {foreach from=$products item=product name=products}
             {$GREKA}
       {/foreach}


Found out how to do it, i had to add it to an array and create 2 more arrays and add those to another query ... 

use 
{$product.GREKA}

inside the foreach and that's it
For more info on how foreach works in smarty: http://www.smarty.net/docs/en/language.function.foreach.tpl

I get this error: Notice: Undefined index: GREKA im not sure but i think an array with values is being set somewhere in Prestashop for the search output.
