在magento报价中设置和检索选项

I am fairly new to magento and PHP so please forgive me if the solution is obvious, but I am having trouble setting options in a quote item and then retrieving them later. The code I have been writing is extension code in the restservice folder and is as follows:

function AddToCart($email, $productId, $quantity, $colour, $size){        

$customer = GetCustomer($email);
$product = GetProduct($productId);

    $quote = Mage::getModel('sales/quote')->loadByCustomer($customer);
    $quote->setStoreId(Mage::app()->getStore()->getId());
    $quote->assignCustomer($customer);
    $options = array("product_id" => $productId,
                    "qty" => $quantity,
                    "options" => array ("colour" => $colour,
                                        "size" => $size));

    $optionsParam = new Varien_Object();
    $optionsParam->setData($options);

    $quote->addProduct($product, $optionsParam);

    $quote->collectTotals()->save();
}

and the code to retrieve it:

FormatQuoteItems($quote_items){
$results = array();
foreach ($quote_items as $quote_item) {
    $id = $quote_item->getId();
    $price = $quote_item->getPrice();
    $quantity = intval($quote_item->getQty());
    $colouroption = $quote_item->getOptionByCode("colour");
    $sizeoption = $quote_item->getOptionByCode("size");
    $colour = $colouroption->getValue();
    $size = $sizeoption->getValue();
    $results[$id] = array("Id" => $id, 
                          "ProductId" => $quote_item->getProductId(), 
                          "Name" => $quote_item->getName(), 
                          "Barcode" => $quote_item->getSku(), 
                          "Quantity" => $quantity, 
                          "Price" => $price, 
                          "Total" => $quantity * $price, 
                          "Colour" => $colour,
                          "Size" => $size);
}

return array_values($results);
}

I have tried different ideas from snippets of code posted on forums but it seems so straight forward what I am trying to achieve that I must be missing something obvious. Any pointers warmly welcomed, thanks.

Can you post what you get from your return array_values please? It looks like there may be an issue with straight up object relations but need to see the output.