I would like to add some additional fields to the newsletter table. How do I go about rewriting the Newsletter subscriber table to add those fields?
I am expecting to add things like firstname, last name etc.
I would like to add some additional fields to the newsletter table. How do I go about rewriting the Newsletter subscriber table to add those fields?
I am expecting to add things like firstname, last name etc.
Magento\Newsletter\Setup\InstallSchema as an example)below is code which will help you i gave example of adding field to orders table
in app\code\Sugarcode\Test\Setup\UpgradeSchema.php
if (version_compare($context->getVersion(), '2.0.5', '<')) {
$connection = $setup->getConnection();
$tableNames=['sales_order_item','sales_invoice_item','quote_item'];
// Declare data
$columns = [
'custom_sku' => [
'type' => Table::TYPE_TEXT,
'nullable' => false,
'LENGTH' =>255,
'comment' => 'custom sku',
],
];
$connection = $setup->getConnection();
foreach ($tableNames as $tableName) {
foreach ($columns as $name => $definition) {
$connection->addColumn($tableName, $name, $definition);
}
}
$tableNames=['sales_order','sales_invoice','quote'];
// Declare data
$columns = [
'custom_field' => [
'type' => Table::TYPE_TEXT,
'nullable' => false,
'LENGTH' =>255,
'comment' => 'custom Field',
],
];
$connection = $setup->getConnection();
foreach ($tableNames as $tableName) {
foreach ($columns as $name => $definition) {
$connection->addColumn($tableName, $name, $definition);
}
}
// Changes here.
}
SELECT *was used). – Alex Paliarush Jan 08 '16 at 20:18