Advertisement
Guest User

Untitled

a guest
Dec 26th, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. namespace vendor\module\Setup;
  4.  
  5. use Magento\Framework\Setup\InstallSchemaInterface;
  6. use Magento\Framework\Setup\ModuleContextInterface;
  7. use Magento\Framework\Setup\SchemaSetupInterface;
  8.  
  9. class InstallSchema implements InstallSchemaInterface
  10. {
  11.  
  12. /**
  13. * {@inheritdoc}
  14. * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  15. */
  16. public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
  17. {
  18. $installer = $setup;
  19.  
  20. $installer->startSetup();
  21.  
  22. /* While module install, creates column in sales_order_grid table */
  23.  
  24. $eavTable = $installer->getTable('sales_order_grid');
  25.  
  26. $columns = [
  27. 'coupon_code' => [
  28. 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
  29. 'nullable' => true,
  30. 'comment' => 'Coupon Code',
  31. ],
  32. ];
  33.  
  34. $connection = $installer->getConnection();
  35. foreach ($columns as $name => $definition) {
  36. $connection->addColumn($eavTable, $name, $definition);
  37. }
  38.  
  39. $installer->endSetup();
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement