Is it possible to add/update a customers cart from admin?
$productId = 700;
$storeId = Mage::app()->getStore()->getId();
$product = Mage::getModel('catalog/product')
->setStoreId($storeId)
->load($productId);
$qty = 1;
$cart = Mage::getModel('sales/quote');
$cart->setStore(Mage::app()->getStore())->loadByCustomer($customer->getId());
if (!$cart->getId())
{
$cart->assignCustomer($customer);
$cart->save();
}
$info = new Varien_Object(array(
'product_id' => $product->getId(),
'qty' => $qty
));
$cart->addProduct($product, $info );
$cart->collectTotals()->save();
This is writing an entry into the sales_flat_quote table but it is not showing up in the customers cart. I am doing something wrong or missing something.
Best Answer
Yes it's possible.
Find the customer in the backend, click on edit.
You should see a tab on the left called shopping cart. You would expect that it should work from there. But it doesn't. Or at least I didn't find a way to make it work.
But here is how I did.
Click on the 'Create order' from the customer edit screen.
Select a store view to associate the order with.
Then add to the order the products you want to put in the cart.
After adding them, you will see for each line a column named
Action
. Select from the dropdown for each product "Move to shopping cart".Then hit "Update items and qty's".
That's it.
I know it seams like a strange process, but if you need it badly you can use it.