Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A workaround:</p> <p>Add this rewrite to a custom module (ie. catalogextended) in config.xml</p> <pre><code> &lt;models&gt; &lt;catalogextended&gt; &lt;class&gt;Myname_Catalogextended_Model&lt;/class&gt; &lt;/catalogextended&gt; &lt;catalog&gt; &lt;rewrite&gt; &lt;category_attribute_backend_image&gt;Myname_Catalogextended_Model_Category_Attribute_Backend_Image&lt;/category_attribute_backend_image&gt; &lt;/rewrite&gt; &lt;/catalog&gt; &lt;/models&gt; </code></pre> <p>And add this file: </p> <pre><code>app/code/local/Myname/Catalogextended/Model/Category/Attribute/Backend/Image.php </code></pre> <p>Containing:</p> <p> <pre><code>/** * Save uploaded file and set its name to category * * @param Varien_Object $object */ public function afterSave($object) { $value = $object-&gt;getData($this-&gt;getAttribute()-&gt;getName()); if (is_array($value) &amp;&amp; !empty($value['delete'])) { $object-&gt;setData($this-&gt;getAttribute()-&gt;getName(), ''); $this-&gt;getAttribute()-&gt;getEntity() -&gt;saveAttribute($object, $this-&gt;getAttribute()-&gt;getName()); return; } /* Workaround to avoid exception '$_FILES array is empty' when assiging * products to a category or creating a category with the API. * Inspired by http://www.magentocommerce.com/bug-tracking/issue/?issue=11597 */ if (!isset($_FILES) || count($_FILES) == 0) { return; } $path = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; try { $uploader = new Mage_Core_Model_File_Uploader($this-&gt;getAttribute()-&gt;getName()); $uploader-&gt;setAllowedExtensions(array('jpg','jpeg','gif','png')); $uploader-&gt;setAllowRenameFiles(true); $result = $uploader-&gt;save($path); $object-&gt;setData($this-&gt;getAttribute()-&gt;getName(), $result['file']); $this-&gt;getAttribute()-&gt;getEntity()-&gt;saveAttribute($object, $this-&gt;getAttribute()-&gt;getName()); } catch (Exception $e) { if ($e-&gt;getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) { Mage::logException($e); } /** @TODO ??? */ return; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload