this prestashop hook give me only the first result even if the customer buy 2 items,
public function hookDisplayAdminOrder($params) {
$id_order = (int) Tools::getValue('id_order');
// Get all products associated with the order
$sql = 'SELECT product_id FROM '._DB_PREFIX_.'order_detail WHERE id_order = '.(int) $id_order;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
$product_ids = array();
foreach ($result as $row) {
$product_ids[] = $row['product_id'];
}
// Iterate over all products
foreach ($product_ids as $product_id) {
// Obter informações do produto
$sql_product = 'SELECT url FROM '._DB_PREFIX_.'scrape_ali_info WHERE id_product='.(int) $product_id;
$product_data = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql_product);
// Do something with product information
$this->context->smarty->assign(array(
'id_produto' => $product_id,
'ali_url' => $product_data['url'],
'id_order' => $id_order
));
// Here you can make decisions about what to do with the data, or just display it
echo $this->display(__FILE__, 'views/templates/admin/[login to view URL]');
}
}
when I try to do echo inside, its not working.
someone can only edit this code to make it work.