0

I want to create a image uploader on catalog/category/index/ just like homepage image which is on catalog/category/index/ page

already exist image uploader on catalog/category/index

Now I am using this to create same above but not success

InstallData.php

eavSetupFactory = $eavSetupFactory; } public function install( ModuleDataSetupInterface $setup, ModuleContextInterface $context ) { $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $eavSetup->addAttribute( \Magento\Catalog\Model\Category::ENTITY, 'category_child_image', [ 'type' => 'varchar', 'label' => 'Category Child Image', 'name' => 'Category Child Image', 'input' => 'image', 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'user_defined' => true, 'group' => 'General Information' ] ); } } category_form.xml false false Iversa_StaticCategoryImage/form/element/custom-button category_child_image category_child_image file -->
                <item name="sortOrder" xsi:type="number">333</item>
                <item name="dataType" xsi:type="string">string</item>
                <item name="formElement" xsi:type="string">image</item>
                <item name="label" translate="true" xsi:type="string">Category Child Image</item>
            </item>
        </argument>
    </field>
</fieldset>

custom-button.html

Select from Gallery

and I got this result of code please help me

1 Answer 1

0

You need to create a file "UpgradeData.php"

UpgradeData - this class will run when the module is upgraded to add/remove data from table.

will be located at app/code/Vendor/Module/Setup folder. The module install/upgrade script will run when you run the following command line:

php bin/magento setup:upgrade

Make sure to upgrade module version to higher then the current

& use this in upgrade script

if (version_compare($context->getVersion(), '1.2.0', '<')) 

Take a look at other upgrade.php to get more idea about its code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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