ZiedDams Posted September 21, 2022 Share Posted September 21, 2022 Hi , can any one help me with this SQL query to select a list of pack products only i mean this SELECT id_product from ps_product where ? = ? Link to comment Share on other sites More sharing options...
ps8modules Posted September 21, 2022 Share Posted September 21, 2022 Hi, choose products in a pack for a specific product? Why SQL, when Prestashop has functions for it? Link to comment Share on other sites More sharing options...
ZiedDams Posted September 21, 2022 Author Share Posted September 21, 2022 Just now, 4you.software said: Hi, choose products in a pack for a specific product? Why SQL, when Prestashop has functions for it? i want to display a list of packs in custom FrontController but i don't know how to get them, if you tell me the function name this will be helpful , thank you Link to comment Share on other sites More sharing options...
ps8modules Posted September 21, 2022 Share Posted September 21, 2022 (edited) Ok. $id_lang = $this->context->language->id; $id_product = Tools::getValue('id_product'); if (Pack::isPack($id_product)){ $pack = Pack::getItems($id_product, $id_lang); $this->context->smarty->assign('my_custom_pack', $pack); } Edited September 21, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
ps8modules Posted September 21, 2022 Share Posted September 21, 2022 (edited) for all products sample: $getPackedProducts = Db::getInstance()->executeS('SELECT id_product_pack FROM '._DB_PREFIX_.'pack GROUP BY id_product_pack'); $pack = array(); $id_lang = $this->context->language->id; foreach ($getPackedProducts as $product){ $id_product = $product['id_product_pack']; $pack[] = Pack::getItems($id_product, $id_lang); } $this->context->smarty->assign('my_custom_pack', $pack); Edited September 21, 2022 by 4you.software (see edit history) 1 1 Link to comment Share on other sites More sharing options...
ZiedDams Posted September 22, 2022 Author Share Posted September 22, 2022 15 hours ago, 4you.software said: for all products sample: $getPackedProducts = Db::getInstance()->executeS('SELECT id_product_pack FROM '._DB_PREFIX_.'pack GROUP BY id_product_pack'); $pack = array(); $id_lang = $this->context->language->id; foreach ($getPackedProducts as $product){ $id_product = $product['id_product_pack']; $pack[] = Pack::getItems($id_product, $id_lang); } $this->context->smarty->assign('my_custom_pack', $pack); Thank you so much. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted September 22, 2022 Share Posted September 22, 2022 I gladly helped 😄 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now