I have added a custom attribute in existing table catalog_category. The following code i have write in InstallData.php.
namespace BelVG\AdditionalImageTemplate\Setup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Catalog\Setup\CategorySetupFactory;
/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface {
/**
* Category setup factory
*
* @var CategorySetupFactory
*/
private $categorySetupFactory;
/**
* Init
*
* @param CategorySetupFactory $categorySetupFactory
*/
public function __construct(
CategorySetupFactory $categorySetupFactory
) {
$this->categorySetupFactory = $categorySetupFactory;
}
/**
* {@inheritdoc}
*/
public function install(
ModuleDataSetupInterface $setup, ModuleContextInterface $context
) {
$installer = $setup;
$setup->startSetup();
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Category::ENTITY);
$attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
$categorySetup->addAttribute(
'catalog_category', 'additional_image', [
'type' => 'varchar',
'label' => 'Additional Image',
'input' => 'image',
'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image',
'required' => false,
'sort_order' => 100,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]
);
$installer->endSetup();
$setup->endSetup();
}
}
This works fine and I got the entry in eav_attribute
table.
After that I created a Thumbnail Image in backend category form
and that too works fine.
But I did not get where the actual values of the image I upload from backend side is stored and how to fetch that values?
Basically I need the image name and url of the image.
catalog_category_entity_varchar
should be the table. There you need to joineav_attribute
andcatalog_category_entity_varchar
to get your desired value