I'm trying to add a new custom image attribute for category, following the guide here "https://webkul.com/blog/add-custom-image-attribute-category-magento-2/comment-page-1/#comment-16835"
However, after I added these files under /app/code/[vendor]/[Module]/
Then run
php bin/magento setup:di:compile 
php bin/magento setup:upgrade 
php bin/magento c:c c:f
but nothing shows up, and I cannot find the module on the list. Please help
1 Answer 1
You can create your own custom module wherein you can use the resources from the guide provided in a link included in your post.
Follow the steps below
registration.php
app/code/Vendor/CustomModule/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
 \Magento\Framework\Component\ComponentRegistrar::MODULE,
 'Vendor_CustomModule',
 __DIR__
); 
module.xml
app/code/Vendor/CustomModule/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
 <module name="Vendor_CustomModule" setup_version="1.0.0" />
</config> 
- 
 1This works, thanks a lot. After created the registration.php file, I had to delete the Vendor/Module/di.xml from the guide which was causing error, and replace the module.xml you provided. After that, just run setup:upgrade, and everything works now! Thanks, i'm new to creating modules.Mage Explorer– Mage Explorer2019年02月08日 23:15:43 +00:00Commented Feb 8, 2019 at 23:15
- 
 Can you show me how to call the image in the front end?Mage Explorer– Mage Explorer2019年02月08日 23:52:46 +00:00Commented Feb 8, 2019 at 23:52
- 
 it's on the comment: Please follow below steps in order to get image url at frontend. create instance of class Magento\Catalog\Model\CategoryRepository then get category model by calling get method like $category = $categoryRepository->get($categoryId, $storeId); $imageUrl = "magento_media_url_path"."catalog/category/".$category->getCustomImage(); And then you can use this $imageUrl in your custom category page or as per your design.fmsthird– fmsthird2019年02月09日 02:04:04 +00:00Commented Feb 9, 2019 at 2:04
Explore related questions
See similar questions with these tags.
php bin/magento s:s:d