is this possible?
i get no new row in the catalog_product_entity table - the other entrys in the tables works...
<?php namespace MyVendor\MyModule\Setup; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; class InstallSchema implements InstallSchemaInterface { /** * Install * * @param SchemaSetupInterface $setup * @param ModuleContextInterface $context */ public function install( SchemaSetupInterface $setup, ModuleContextInterface $context ) { $installer = $setup; $installer->startSetup(); /* quote table */ $installer->getConnection()->addColumn( $installer->getTable('quote_item'), 'rendering_id', [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Rendering ID', ] ); /* sales_order table */ $installer->getConnection()->addColumn( $installer->getTable('sales_order_item'), 'rendering_id', [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Rendering ID', ] ); /* catalog_product_entity table */ $installer->getConnection()->addColumn( $installer->getTable('catalog_product_entity'), 'rendering_id', [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Rendering ID', ] ); /* quote table */ $installer->getConnection()->addColumn( $installer->getTable('quote_item'), 'filename', [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Filename', ] ); /* sales_order table */ $installer->getConnection()->addColumn( $installer->getTable('sales_order_item'), 'filename', [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Filename', ] ); /* catalog_product_entity table */ $installer->getConnection()->addColumn( $installer->getTable('catalog_product_entity'), 'filename', [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Filename', ] ); $setup->endSetup(); } }
You Need to use Install_data files for altering existing table of magento.
here is the code
<?php namespace Vendor\Extension\Setup; use Magento\Catalog\Setup\CategorySetupFactory; use Magento\Eav\Setup\EavSetupFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $eavSetupFactory; private $categorySetupFactory; public function __construct( EavSetupFactory $eavSetupFactory, CategorySetupFactory $categorySetupFactory ) { $this->eavSetupFactory = $eavSetupFactory; $this->categorySetupFactory = $categorySetupFactory; } public function install( ModuleDataSetupInterface $setup, ModuleContextInterface $context ) { $setup->startSetup(); $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); // Product Attribute $eavSetup->addAttribute( \Magento\Catalog\Model\Product::ENTITY, 'recored', [ 'type' => 'varchar', 'label' => 'Recored', 'input' => 'multiselect', 'source' => \Vendor\Extension\Model\Product\Attribute\Source\Citys::class, 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class, 'required' => false, 'sort_order' => 50, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'group' => 'Product Details', 'is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false ] ); $setup->endSetup(); } }