1

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

  • I too am looking for a solution similar to this... However, if you save the item in this way, each file that was uploaded would be added to the product... or overwritten each time. Instead, you would need to programatically duplicate the product in the database and add the option to the duplicate product, then add the duplicate product to the cart. Any ideas? – AssociatedVOIP.com Oct 15 '14 at 23:10
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.