How to add multiple products to cart

Hello all,

How to add multiple products(like 3 products) to the cart programmatically.

Can anyone please give me the solution

Thanks in advance.

Simply build an array with at least productids and amounts.
In forach of the array call the basket an add the products with addToBasket($id,$amount).

@rubbercut Thank you for your quick and valuable feedback.

Could you please share the sample code snippet.

$id = "productid1";
$amount = 1;
$intobasket[] = array($id,$amount);

$id = "productid2";
$amount = 2;
$intobasket[] = array($id,$amount);

foreach($intobasket as $values){
$oBasket = Registry::getSession()->getBasket();
$oBasket->addToBasket($values[0], $values[1]);