I have below code to create cart and addProduct :
$quote = Mage::getModel('sales/quote')->setStoreId(1);
$quote->assignCustomer($customer);
$product = Mage::getModel('catalog/product')->load($productId);
$quote->addProduct($product, new Varien_Object(array('qty' => 1)));
$quote->save();
Above code creating corresponding rows in quote tables, but when I'm checking on frontend cart page for same customer then I'm getting Cart is empty on cart page.
But when I try to addproduct in existing cart which is created from frontend using below code :
$quote = Mage::getModel('sales/quote')->load($cartId);
$quote->assignCustomer($customer);
$product = Mage::getModel('catalog/product')->load($productId);
$quote->addProduct($product, new Varien_Object(array('qty' => 1)));
$quote->save();
then the programmatically added product is coming on frontend.
Why this is happening?