Jump to content

list accessoiries by name in product page(1.60.11)


mrweb

Recommended Posts

Hi

 

i need to list the accessoiries in 1 product page by name

 

i tried to update the function (classes/prioduct.php)

    public static function getAccessoriesLight($id_lang, $id_product, Context $context = null)
    {
        return Db::getInstance()->executeS('
            SELECT p.`id_product`, p.`reference`, pl.`name`
            FROM `'._DB_PREFIX_.'accessory`
            LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product`= `id_product_2`)
            '.Shop::addSqlAssociation('product', 'p').'
            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
                p.`id_product` = pl.`id_product`
                AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
            )
            WHERE `id_product_1` = '.(int)$id_product
        );
    }

 

but when i update it with ORDER BY pl.`name`, i get a blank page

 

Please, someone can help me ?

 

Thanks!

Link to comment
Share on other sites

Blank page indicates some (syntax) error.

 

Did you correctly concat the order by part to the existing sql query string?

 

return Db::getInstance()->executeS('
            SELECT p.`id_product`, p.`reference`, pl.`name`
            FROM `'._DB_PREFIX_.'accessory`
            LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product`= `id_product_2`)
            '.Shop::addSqlAssociation('product', 'p').'
            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
                p.`id_product` = pl.`id_product`
                AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
            )
            WHERE `id_product_1` = '.(int)$id_product .'
 ORDER BY pl.`name`'
        );

 

(don't forget the dot, the single, straight quotes and a space before ORDER)

 

 

If this doesn't help, turn on the debug mode, and see what error you get. This may help you find the solution. If you can't figure it out, copy the error message here, and we can have a look.

 

 

pascal

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