Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. use MagentoCustomerModelCustomer;
  2. use MagentoCustomerSetupCustomerSetupFactory;
  3. use MagentoEavModelEntityAttributeScopedAttributeInterface;
  4. use MagentoEavModelEntityAttributeSetFactory;
  5. use MagentoEavModelEntityAttributeSourceBoolean;
  6. use MagentoEavModelEntityType;
  7. use MagentoFrameworkDBDdlTable;
  8. use MagentoFrameworkSetupInstallDataInterface;
  9. use MagentoFrameworkSetupModuleContextInterface;
  10. use MagentoFrameworkSetupModuleDataSetupInterface;
  11.  
  12. class InstallData implements InstallDataInterface
  13. {
  14. private $customerSetupFactory;
  15. private $attributeSetFactory;
  16.  
  17. public function __construct(CustomerSetupFactory $customerSetupFactory, SetFactory $attributeSetFactory)
  18. {
  19. $this->customerSetupFactory = $customerSetupFactory;
  20. $this->attributeSetFactory = $attributeSetFactory;
  21. }
  22.  
  23. public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
  24. {
  25. $installer = $setup;
  26. $installer->startSetup();
  27.  
  28. $customerSetup = $this->customerSetupFactory->create(['setup'=>$setup]);
  29. $customerSetup->removeAttribute(Customer::ENTITY, 'exported_to_stannp');
  30.  
  31. $customerEntity = $customerSetup->getEavConfig()->getEntityType(Customer::ENTITY);
  32. $attributeSetId = $customerEntity->getDefaultAttributeSetId();
  33.  
  34. $attributeSet = $this->attributeSetFactory->create();
  35. $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
  36.  
  37. $entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
  38.  
  39. $customerSetup->addAttribute(
  40. Customer::ENTITY, 'exported_to_stannp', [
  41. // 'type' => 'int',
  42. 'backend' => MagentoCustomerModelAttributeBackendDataBoolean::class,
  43. 'frontend' => '',
  44. 'label' => 'Exported to Stannp',
  45. 'input' => 'select',
  46. 'source' => MagentoEavModelEntityAttributeSourceBoolean::class,
  47. 'required' => false,
  48. 'visible' => true,
  49. 'user_defined' => true,
  50. 'system' => false,
  51. 'adminhtml_only' => true,
  52. 'default' => 0,
  53. 'global' => ScopedAttributeInterface::SCOPE_STORE,
  54. 'value' => 0,
  55. 'is_used_in_customer_segment' => true,
  56. "is_used_in_grid" => true,
  57. "is_visible_in_grid" => true,
  58. "is_filterable_in_grid" => true,
  59. "is_searchable_in_grid" => false
  60. ]
  61. );
  62.  
  63. $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'exported_to_stannp')
  64. ->addData(
  65. [
  66. 'attribute_set_id' => $attributeSetId,
  67. 'attribute_group_id' => $attributeGroupId,
  68. 'used_in_forms' => ['adminhtml_customer']
  69. ]
  70. )->save();
  71.  
  72.  
  73. $installer->endSetup();
  74. }
  75.  
  76. }
  77.  
  78. <?xml version="1.0" encoding="UTF-8"?>
  79. <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
  80. <columns name="customer_columns">
  81. <column name="exported_to_stannp">
  82. <argument name="data" xsi:type="array">
  83. <item name="options" xsi:type="object">MagentoConfigModelConfigSourceYesno</item>
  84. <item name="config" xsi:type="array">
  85. <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
  86. <item name="filter" xsi:type="string">select</item>
  87. <item name="visible" xsi:type="boolean">true</item>
  88. <item name="editor" xsi:type="string">select</item>
  89. <item name="dataType" xsi:type="string">select</item>
  90. <item name="label" xsi:type="string" translate="true">Exported to Stannp</item>
  91. <item name="source" xsi:type="string">customer</item>
  92. <item name="sortOrder" xsi:type="number">166</item>
  93. </item>
  94. </argument>
  95. </column>
  96. </columns>
  97. </listing>
  98.  
  99. <?xml version="1.0"?>
  100. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
  101. <indexer id="customer_grid">
  102. <fieldset name="customer" source="MagentoCustomerModelResourceModelCustomerCollection" provider="MagentoCustomerModelIndexerAttributeProvider">
  103. <field name="exported_to_stannp" xsi:type="filterable" dataType="int"/>
  104. </fieldset>
  105. </indexer>
  106. </config>
  107.  
  108. 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