I'm too new to Magento
: i'm getting an error when setup:upgrade
, here is my code:
app/code/Adamsmage/Checkoutattribute/Setup/InstallData.php
<?php
namespace Adamsmage\Checkoutattribute\Setup;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Customer\Model\Customer;
use Magento\Customer\Setup\CustomerSetupFactory;
class InstallData implements InstallDataInterface
{
private $customerSetupFactory;
/**
* Constructor
*
* @param \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory
*/
public function __construct(
CustomerSetupFactory $customerSetupFactory
) {
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* {@inheritdoc}
*/
public function install(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
) {
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$customerSetup->addAttribute('customer_address', 'example', [
'label' => 'example',
'input' => 'text',
'type' => 'varchar',
'source' => '',
'required' => false,
'position' => 333,
'visible' => true,
'system' => false,
'is_used_in_grid' => false,
'is_visible_in_grid' => false,
'is_filterable_in_grid' => false,
'is_searchable_in_grid' => false,
'backend' => ''
]);
$attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'example')
->addData(['used_in_forms' => [
'customer_address_edit',
'customer_register_address',
'adminhtml_customer_address',
'customer_address'
]]);
$attribute->save();
$installer->getConnection()->addColumn(
$installer->getTable('quote_address'),
'example',
[
'type' => 'varchar',
'length' => 255
]
);
$installer->getConnection()->addColumn(
$installer->getTable('sales_order_address'),
'example',
[
'type' => 'varchar',
'length' => 255
]
);
}
}
Impossible to create a column without comment.
– Partab Saifuddin Zakir Jul 18 '19 at 15:20Invalid column definition data
– Partab Saifuddin Zakir Jul 18 '19 at 15:45