I'm working with a function that runs immediately after a user submits an order to his/her Magento shopping cart, and I'm trying to get the URL for the file the user has just uploaded, so that I can manipulate it before the order is officially submitted.

I'm getting the quote data correct, and when I output the object with print_r, I can SEE where the URL is in the object data, but I can't write the code to actually pull that specifically. Here's a snippet of my function:

        class Image_Processor_Model_Observer {
          public function autoMetaDescription(Varien_Event_Observer $observer) {

          $checkout = Mage::getSingleton('checkout/session')->getQuote();
          $options = $checkout->getProductOptions();
          $sales_quote = $options->sales_quote;

          print "<pre>";
          print "</pre>";


And here's a snippet of the output I'd like to access:

[option_3] => Mage_Sales_Model_Quote_Item_Option Object
                                                                    [_item:protected] => Mage_Sales_Model_Quote_Item Object
                                                                    [_product:protected] => Mage_Catalog_Model_Product Object
                                                                    [_eventPrefix:protected] => core_abstract
                                                                    [_eventObject:protected] => object
                                                                    [_resourceName:protected] => sales/quote_item_option
                                                                    [_resource:protected] => 
                                                                    [_resourceCollectionName:protected] => sales/quote_item_option_collection
                                                                    [_cacheTag:protected] => 
                                                                    [_dataSaveAllowed:protected] => 1
                                                                    [_isObjectNew:protected] => 
                                                                    [_data:protected] => Array
                                                                            [product_id] => 3
                                                                            [product] => Mage_Catalog_Model_Product Object
                                                                            [code] => option_3
                                                                            [value] => a:9:{s:4:"type";s:24:"application/octet-stream";s:5:"title";s:19:"EatingBreakfast.jpg";s:10:"quote_path";s:68:"\media\custom_options\quote\E\a\9884fbc76ede5ddb9ef991b83c17f8ae.jpg";s:10:"order_path";s:68:"\media\custom_options\order\E\a\9884fbc76ede5ddb9ef991b83c17f8ae.jpg";s:8:"fullpath";s:93:"D:\Our Files\Web\lifewall\media\custom_options\quote\E\a\9884fbc76ede5ddb9ef991b83c17f8ae.jpg";s:4:"size";s:7:"8050795";s:5:"width";i:3000;s:6:"height";i:3997;s:10:"secret_key";s:20:"9884fbc76ede5ddb9ef9";}
                                                                            [item_id] => 

                                                                    [_hasDataChanges:protected] => 1
                                                                    [_origData:protected] => 
                                                                    [_idFieldName:protected] => 
                                                                    [_isDeleted:protected] => 
                                                                    [_oldFieldsMap:protected] => Array

                                                                    [_syncFieldsMap:protected] => Array


I hope that's all clear. I just need the .jpg path you see in the 'value' part of the output. Any ideas how to pull that? Thanks!

1 Answer 1


You should be able to go $uploadedImage = json_decode($checkout->getValue()); to decode the submitted values. You then should be able to then use $path = $uploadedImage->fullpath to get the full path of the image which in your example is D:\Our Files\Web\lifewall\media\custom_options\quote\E\a\9884fbc76ede5ddb9ef991b83c17f8ae.jpg or you could use $url= $uploadedImage->quote_path to get the url \media\custom_options\quote\E\a\9884fbc76ede5ddb9ef991b83c17f8ae.jpg and then use $fullUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $url

  • Hi, rob3000 -- Thanks for the help. Unfortunately, it doesn't seem to work. I'm using this: $quote = Mage::getSingleton('checkout/session')->getQuote(); $uploadedImage = json_decode($quote->getValue()); $path = $uploadedImage->fullpath; $url= $uploadedImage->quote_path; $fullUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $url; ` And I'm not able to output any value from $url or $path, even though the values are in that big print_r() output of $quote. Any other suggestions? Commented Oct 16, 2015 at 2:59
  • If you print_r $uploadedImage is anything in there?
    – rob3000
    Commented Oct 16, 2015 at 3:06
  • If do print_r($uploadedImage), the number '1' is the only thing that's outputted to the screen. Commented Oct 16, 2015 at 3:17
  • can you print_r($quote->getData());
    – rob3000
    Commented Oct 16, 2015 at 3:41
  • Yes, I can print that, but all I get for output is this: Array ( [store_id] => 1 [is_checkout_cart] => 1 [remote_ip] => [x_forwarded_for] => ) 1 Thanks for the continued help, by the way! Commented Oct 17, 2015 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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