119 lines
3.9 KiB
PHP
119 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace Stemcell\Customer\Setup;
|
|
|
|
use Magento\Customer\Model\Customer;
|
|
use Magento\Framework\Setup\InstallDataInterface;
|
|
use Magento\Framework\Setup\SchemaSetupInterface;
|
|
use Magento\Framework\Setup\UpgradeSchemaInterface;
|
|
use Magento\Framework\Setup\ModuleContextInterface;
|
|
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
|
use Stemcell\Customer\Model\Attribute\Source\CustomerType;
|
|
use Stemcell\Customer\Model\Attribute\Source\ResearchFields;
|
|
|
|
class RegistryInstallData implements UpgradeSchemaInterface
|
|
{
|
|
protected $eavSetupFactory;
|
|
|
|
public function __construct(
|
|
\Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
|
|
){
|
|
$this->eavSetupFactory = $eavSetupFactory;
|
|
}
|
|
|
|
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
|
|
{
|
|
$eavSetup = $this->eavSetupFactory->create();
|
|
$eavSetup->addAttribute(
|
|
Customer::ENTITY,
|
|
'customer_type',
|
|
[
|
|
'label' => 'Customer Type',
|
|
'input' => 'select',
|
|
'type' => 'static',
|
|
'source' => CustomerType::class,
|
|
'required' => false,
|
|
'position' => 333,
|
|
'visible' => false,
|
|
'system' => false,
|
|
'is_used_in_grid' => true,
|
|
'is_visible_in_grid' => true,
|
|
'is_filterable_in_grid' => true,
|
|
'is_searchable_in_grid' => false,
|
|
]
|
|
);
|
|
//公司或单位名称
|
|
$eavSetup->addAttribute(
|
|
Customer::ENTITY,
|
|
'company_name',
|
|
[
|
|
'label' => 'Company Name',
|
|
'input' => 'text',
|
|
'type' => 'varchar',
|
|
'required' => false,
|
|
'position' => 334,
|
|
'visible' => true,
|
|
'system' => false,
|
|
'is_used_in_grid' => true,
|
|
'is_visible_in_grid' => true,
|
|
'is_filterable_in_grid' => true,
|
|
'is_searchable_in_grid' => false
|
|
]
|
|
);
|
|
$eavSetup->addAttribute(
|
|
Customer::ENTITY,
|
|
'company_address',
|
|
[
|
|
'label' => 'Company Address',
|
|
'input' => 'text',
|
|
'type' => 'varchar',
|
|
'required' => false,
|
|
'position' => 335,
|
|
'visible' => true,
|
|
'system' => false,
|
|
'is_used_in_grid' => true,
|
|
'is_visible_in_grid' => true,
|
|
'is_filterable_in_grid' => true,
|
|
'is_searchable_in_grid' => false
|
|
]
|
|
);
|
|
//课题组、部门
|
|
$eavSetup->addAttribute(
|
|
Customer::ENTITY,
|
|
'department',
|
|
[
|
|
'label' => 'Department',
|
|
'input' => 'text',
|
|
'type' => 'varchar',
|
|
'required' => false,
|
|
'position' => 335,
|
|
'visible' => true,
|
|
'system' => false,
|
|
'is_used_in_grid' => true,
|
|
'is_visible_in_grid' => true,
|
|
'is_filterable_in_grid' => true,
|
|
'is_searchable_in_grid' => false
|
|
]
|
|
);
|
|
//研究方向
|
|
$eavSetup->addAttribute(
|
|
Customer::ENTITY,
|
|
'research_fields',
|
|
[
|
|
'label' => 'Research Fields',
|
|
'input' => 'multiselect',
|
|
'type' => 'varchar',
|
|
'required' => false,
|
|
'position' => 335,
|
|
'visible' => true,
|
|
'system' => false,
|
|
'is_used_in_grid' => true,
|
|
'is_visible_in_grid' => true,
|
|
'is_filterable_in_grid' => true,
|
|
'is_searchable_in_grid' => false,
|
|
'source' => ResearchFields::class
|
|
]
|
|
);
|
|
}
|
|
}
|