0
votes

In magento customization tool, you can put file upload option

but I would like that When you upload an image preview in the screen at least when you click on edit the product

which is the variable of the loaded image? With The URL of the cart image link:

htt....MY-WEB.com/sales/download/downloadCustomOption/id/107/key/a5cae363d3d6cde2e9c6/

I test with: img src=.. this URL and display ok, but which is the variable that takes this to interfere with an echo

Here they do with flash but if you do not have flash detected with ajax http://demo.micosolutions.com/afup/ajax-flash-upload-pro-demo/ajax-flash-uploader-demo.html

I think these are the files that can talk about this:

app/design/frontend/base/default/template/catalog/product/view/options/type/file.phtml

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/file.php

1

1 Answers

0
votes

Edit Deleted old answer because I misunderstood the question.

Ok this time I hope I understood correctly what you want. To get the URL of an custom option image from a product that was added to the cart you can get it from quote item:

    $item = $this->getItem();
    $optionIds = $item->getOptionByCode('option_ids');

    if( $optionIds ) {
      $options = array();
      foreach( explode( ',', $optionIds->getValue() ) as $optionId ) {
        $option = $this->getProduct()->getOptionById( $optionId );

        if( $option->getData( 'type' ) == 'file' ) {
          $option = $item->getOptionByCode( 'option_' . $optionId );

          $value = unserialize( $option->getData( 'value' ) );

          var_dump( $value );
          var_dump( Mage::getUrl( 'sales/download/downloadCustomOption', array( 'id' => $option->getId(), 'key' => $value[ 'secret_key' ] ) ) );

          echo '<img src="' . Mage::getUrl( 'sales/download/downloadCustomOption', array( 'id' => $option->getId(), 'key' => $value[ 'secret_key' ] ) ) . '"/>';
        }
      }
    }

Output: It var dumps download url and $value content ($value[ 'fullpath' ] is the location of the image file but it is forbiddon to access it from a browser - you will have to move the file to a different location in media folder where it will be accessable from the web). echo will show the image.

$item is of type Mage_Sales_Model_Quote_Item (this code was tested in checkout/cart/index controller - your_page_url/index.php/checkout/cart -> code can be added at the top of template/checkout/cart/item/default.phtml file to see how it works).