Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace XXXCustomerstatusSetup;
- use MagentoCustomerSetupCustomerSetupFactory;
- use MagentoCustomerModelCustomer;
- use MagentoEavModelEntityAttributeSet as AttributeSet;
- use MagentoEavModelEntityAttributeSetFactory as AttributeSetFactory;
- use MagentoFrameworkSetupInstallDataInterface;
- use MagentoFrameworkSetupModuleContextInterface;
- use MagentoFrameworkSetupModuleDataSetupInterface;
- class InstallData implements InstallDataInterface
- {
- /**
- * @var CustomerSetupFactory
- */
- protected $customerSetupFactory;
- /**
- * @var AttributeSetFactory
- */
- private $attributeSetFactory;
- /**
- * @param CustomerSetupFactory $customerSetupFactory
- * @param AttributeSetFactory $attributeSetFactory
- */
- public function __construct(
- CustomerSetupFactory $customerSetupFactory,
- AttributeSetFactory $attributeSetFactory
- ) {
- $this->customerSetupFactory = $customerSetupFactory;
- $this->attributeSetFactory = $attributeSetFactory;
- }
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- /** @var CustomerSetup $customerSetup */
- $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
- $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
- $attributeSetId = $customerEntity->getDefaultAttributeSetId();
- /** @var $attributeSet AttributeSet */
- $attributeSet = $this->attributeSetFactory->create();
- $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
- $customerSetup->addAttribute(Customer::ENTITY, 'custom_customer_status_custom', [
- 'type' => 'int',
- 'label' => 'Custom Customer Status',
- 'input' => 'select',
- 'source' => 'MagentoEavModelEntityAttributeSourceTable',
- 'required' => false,
- 'user_defined' => true,
- 'sort_order' => 11,
- 'position' => 11,
- 'system' => false,
- 'option' => ['values' => ['Awaiting Reply', 'Yes', 'No']],
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- ]);
- $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'custom_customer_status_custom')
- ->addData([
- 'attribute_set_id' => $attributeSetId,
- 'attribute_group_id' => $attributeGroupId,
- 'used_in_forms' => ['adminhtml_customer'],
- ]);
- $attribute->save();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement