Jump to content

Prestashop 1.7 Get list of Pack Products


ZiedDams

Recommended Posts

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

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 by 4you.software (see edit history)
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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.

  • Like 1
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...