magento2 - Adding custom Image attribute for category in magento 2 -
i have tried below code adding thumbnail image in category.
when upload image in custom field below error.
error
attention
the file not uploaded.
error: "the file not uploaded." errorcode: 666
category_form.xml
<field name="thumbnail_image"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="datatype" xsi:type="string">string</item> <item name="source" xsi:type="string">category</item> <item name="label" xsi:type="string" translate="true">category image</item> <item name="visible" xsi:type="boolean">true</item> <item name="formelement" xsi:type="string">fileuploader</item> <item name="elementtmpl" xsi:type="string">ui/form/element/uploader/uploader</item> <item name="previewtmpl" xsi:type="string">magento_catalog/image-preview</item> <item name="required" xsi:type="boolean">false</item> <item name="sortorder" xsi:type="number">40</item> <item name="uploaderconfig" xsi:type="array"> <item name="url" xsi:type="url" path="catalog/category_image/upload"/> </item> <item name="label" xsi:type="string" translate="true">thumbnail image</item> </item> </argument> </field>
installdata.php
$eavsetup->addattribute('catalog_category', 'thumbnail_image', array( 'input' => 'image', 'type' => 'varchar', 'backend' => 'catalog/category_attribute_backend_image', 'group' => 'general', 'label' => 'thumbnail image', 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'frontend_input' =>'', 'global' => \magento\catalog\model\resourcemodel\eav\attribute::scope_global, 'visible_on_front' => 1, ));
di.xml
<config xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="../../../../../lib/internal/magento/framework/acl/etc/di.xsd"> <type name="namespace\module\controller\adminhtml\category\image"> <arguments> <argument name="imageuploader" xsi:type="object">magento\catalog\categoryimageupload</argument> </arguments> </type> </config>
you solution listed here : [https://github.com/magento/magento2/issues/5438][1]
there hard coded code category attribute type "image" after
magento
2.1.x release.so can't create custom image attribute.and solution is: need install patch listed on github, can find : [https://github.com/magento/magento2/pull/5970/commits/706845648f3a377e6f40ce0487f961dcfb2a721f][2] here.
i think there not patch available need replace core file manually.
Comments
Post a Comment