Magento – add custom data with quote item magento

magento-1.8

I need a custom field in cart in with I can display uploaded file link. I am uploading file at product view page and handling this in observer. although I have change product custom price and quantity in observer and it working fine. Now further I want to show uploaded file link with each item in cart and want this link in order also.

Code which I am using for this is

$item->addOption(array(
                      "product_id" => $item->getProduct()->getId(),
                      "product" => $item->getProduct(),
                      "code" => "FilePath",
                      "value" => $fileSavedPath
                ));
                 $item->save();

I want to keep $fileSavedPath in a FilePath field.
I am a bigginger and not sure about flow that how would I achieve this. Can any one help. Thanks

Best Answer

I would suggest using Magento's inbuilt custom option for this purpose - see more details on how to use those here Reorder problem with custom quote attribute

You then don't need to worry on saving this with the quote item, order item etc and you can then focus on how to format the display to suit your needs.

Related Topic