Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use MagentoCustomerModelCustomer;
- use MagentoCustomerSetupCustomerSetupFactory;
- use MagentoEavModelEntityAttributeScopedAttributeInterface;
- use MagentoEavModelEntityAttributeSetFactory;
- use MagentoEavModelEntityAttributeSourceBoolean;
- use MagentoEavModelEntityType;
- use MagentoFrameworkDBDdlTable;
- use MagentoFrameworkSetupInstallDataInterface;
- use MagentoFrameworkSetupModuleContextInterface;
- use MagentoFrameworkSetupModuleDataSetupInterface;
- class InstallData implements InstallDataInterface
- {
- private $customerSetupFactory;
- private $attributeSetFactory;
- public function __construct(CustomerSetupFactory $customerSetupFactory, SetFactory $attributeSetFactory)
- {
- $this->customerSetupFactory = $customerSetupFactory;
- $this->attributeSetFactory = $attributeSetFactory;
- }
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $installer = $setup;
- $installer->startSetup();
- $customerSetup = $this->customerSetupFactory->create(['setup'=>$setup]);
- $customerSetup->removeAttribute(Customer::ENTITY, 'exported_to_stannp');
- $customerEntity = $customerSetup->getEavConfig()->getEntityType(Customer::ENTITY);
- $attributeSetId = $customerEntity->getDefaultAttributeSetId();
- $attributeSet = $this->attributeSetFactory->create();
- $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
- $entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
- $customerSetup->addAttribute(
- Customer::ENTITY, 'exported_to_stannp', [
- // 'type' => 'int',
- 'backend' => MagentoCustomerModelAttributeBackendDataBoolean::class,
- 'frontend' => '',
- 'label' => 'Exported to Stannp',
- 'input' => 'select',
- 'source' => MagentoEavModelEntityAttributeSourceBoolean::class,
- 'required' => false,
- 'visible' => true,
- 'user_defined' => true,
- 'system' => false,
- 'adminhtml_only' => true,
- 'default' => 0,
- 'global' => ScopedAttributeInterface::SCOPE_STORE,
- 'value' => 0,
- 'is_used_in_customer_segment' => true,
- "is_used_in_grid" => true,
- "is_visible_in_grid" => true,
- "is_filterable_in_grid" => true,
- "is_searchable_in_grid" => false
- ]
- );
- $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'exported_to_stannp')
- ->addData(
- [
- 'attribute_set_id' => $attributeSetId,
- 'attribute_group_id' => $attributeGroupId,
- 'used_in_forms' => ['adminhtml_customer']
- ]
- )->save();
- $installer->endSetup();
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
- <columns name="customer_columns">
- <column name="exported_to_stannp">
- <argument name="data" xsi:type="array">
- <item name="options" xsi:type="object">MagentoConfigModelConfigSourceYesno</item>
- <item name="config" xsi:type="array">
- <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
- <item name="filter" xsi:type="string">select</item>
- <item name="visible" xsi:type="boolean">true</item>
- <item name="editor" xsi:type="string">select</item>
- <item name="dataType" xsi:type="string">select</item>
- <item name="label" xsi:type="string" translate="true">Exported to Stannp</item>
- <item name="source" xsi:type="string">customer</item>
- <item name="sortOrder" xsi:type="number">166</item>
- </item>
- </argument>
- </column>
- </columns>
- </listing>
- <?xml version="1.0"?>
- <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
- <indexer id="customer_grid">
- <fieldset name="customer" source="MagentoCustomerModelResourceModelCustomerCollection" provider="MagentoCustomerModelIndexerAttributeProvider">
- <field name="exported_to_stannp" xsi:type="filterable" dataType="int"/>
- </fieldset>
- </indexer>
- </config>
- Fatal error: Uncaught TypeError: Argument 2 passed to MagentoFrameworkViewElementUiComponentFactory::argumentsResolver() must be of the type array, null given, called in /Users/iunia/Sites/magento2/vendor/magento/framework/View/Element/UiComponentFactory.php on line 213 and defined in /Users/iunia/Sites/magento2/vendor/magento/framework/View/Element/UiComponentFactory.php on line 164
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement