I need to be able to modify the file of my product file type option after an order has been placed.
I then added, in the frontend order view using a <form>
tag, a choose file button which allow file selection , and a "update file" button which call a custom controller.
In the controller, I can get the form values and the file (verified by Mage::log).
Now I need to update my options parameters (which is not a problem),
BUT, while looking in the original file option structure
<?php Mage::log('option'); Mage::log($_option); ?>
<?php Mage::log('option_value'); Mage::log(unserialize($_option['option_value'])); ?>
we can see :
2014-07-29T06:09:58+00:00 DEBUG (7): option
2014-07-29T06:09:58+00:00 DEBUG (7): Array
(
[label] => Fichiers Gerber
[value] => <a href="http://www.e-circuits.fr/sales/download/downloadCustomOption/id/353/key/c25ad2046b4f47d3dbf1/" target="_blank">ecobiz.pdf.zip</a>
[print_value] => ecobiz.pdf.zip
[option_id] => 6
[option_type] => file
[option_value] => a:10:{s:4:"type";s:15:"application/zip";s:5:"title";s:14:"ecobiz.pdf.zip";s:10:"quote_path";s:68:"/media/custom_options/quote/e/c/c25ad2046b4f47d3dbf136b87c40a61d.zip";s:10:"order_path";s:68:"/media/custom_options/order/e/c/c25ad2046b4f47d3dbf136b87c40a61d.zip";s:8:"fullpath";s:118:"/homepages/20/d524244365/htdocs/e-circuits/magento/media/custom_options/quote/e/c/c25ad2046b4f47d3dbf136b87c40a61d.zip";s:4:"size";s:6:"612878";s:5:"width";i:0;s:6:"height";i:0;s:10:"secret_key";s:20:"c25ad2046b4f47d3dbf1";s:3:"url";a:2:{s:5:"route";s:35:"sales/download/downloadCustomOption";s:6:"params";a:2:{s:2:"id";s:3:"353";s:3:"key";s:20:"c25ad2046b4f47d3dbf1";}}}
[custom_view] => 1
)
2014-07-29T06:09:58+00:00 DEBUG (7): option_value
2014-07-29T06:09:58+00:00 DEBUG (7): Array
(
[type] => application/zip
[title] => ecobiz.pdf.zip
[quote_path] => /media/custom_options/quote/e/c/c25ad2046b4f47d3dbf136b87c40a61d.zip
[order_path] => /media/custom_options/order/e/c/c25ad2046b4f47d3dbf136b87c40a61d.zip
[fullpath] => /homepages/20/d524244365/htdocs/e-circuits/magento/media/custom_options/quote/e/c/c25ad2046b4f47d3dbf136b87c40a61d.zip
[size] => 612878
[width] => 0
[height] => 0
[secret_key] => c25ad2046b4f47d3dbf1
[url] => Array
(
[route] => sales/download/downloadCustomOption
[params] => Array
(
[id] => 353
[key] => c25ad2046b4f47d3dbf1
)
)
)
Also :
1 - files must be copied from tmp to a media directory (here e/c/) How to do that, specially the creation / choice of the "e" and "c" directories? (I do not manage to find the called function in magento files…)
2 - there is a secret key stuff… Is it the same as the URL secret key you call in forms?
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
3 - the final file name seems to be the secret key added to the tmp name of the file you get in the form controller. I am right?
Thank you for your help