cancel
Showing results for 
Search instead for 
Did you mean: 

Add a custom attribute to company

Add a custom attribute to company

Hi,

I'm using B2B etensions and I need to add custom attributes to company entity, editable and searchable on backend.

I found that we don't have a mechanism like Magento has for adding attributes to customer CustomerSetupFactory, neither using EAV approach:

If I try 

 

$this->eavSetup->addAttribute('company', 'attribute_code', [
// Attribute parameters
]);

 I get the error 'Wrong entity ID'.

 

So I would like to know what would be the best and easiest way to add a custom attribute to company entity, having it editable and searchable on company view/edit page (backend).

Thanks.

 

Best

Carlos

1 REPLY

Re: Add a custom attribute to company

Hi @carlos_boita,

 

The Company entity isn't an EAV entity. Is a flat entity.

I guess you will need to add your columns (in this case I guess adding a custom table with the ID to match the company with your fields could be a better/clean approach).

You can check at /vendor/magento/module-company/Setup/InstallData.php who the original tables are being created.

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"