I have created a custom attribute named "Approve Account" while export getting below error.
Fatal error: Uncaught TypeError: Argument 2 passed to Magento\Framework\View\Element\UiComponentFactory::argumentsResolver() must be of the type array, null given, called in /var/www/html/tgbl222/vendor/magento/framework/View/Element/UiComponentFactory.php on line 220 and defined in /var/www/html/tgbl222/vendor/magento/framework/View/Element/UiComponentFactory.php:172 Stack trace: #0 /var/www/html/tgbl222/vendor/magento/framework/View/Element/UiComponentFactory.php(220): Magento\Framework\View\Element\UiComponentFactory->argumentsResolver('approve_account', NULL) #1 /var/www/html/tgbl222/vendor/magento/module-ui/Component/Listing/Columns/Column.php(77): Magento\Framework\View\Element\UiComponentFactory->create('approve_account', 'int', Array) #2 /var/www/html/tgbl222/vendor/magento/module-ui/Component/MassAction/Filter.php(184): Magento\Ui\Component\Listing\Columns\Column->prepare() #3 /var/www/html/tgbl222/generated/code/Magento/Ui/Component/MassAction/Filter/Interceptor.php(63): Magento\Ui\Component\MassAction\Filter->p in /var/www/html/tgbl222/vendor/magento/framework/View/Element/UiComponentFactory.php on line 172
/app/code/Namespace/Module/view/adminhtml/ui_component/customer_listing.xml
<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="approve_account">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">select</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
<item name="dataType" xsi:type="string">select</item>
<item name="label" xsi:type="string" translate="true">Account Active</item>
<item name="sortOrder" xsi:type="number">280</item>
</item>
</argument>
</column>
</columns>
/app/code/Namespace/Module/setup/installData.php
/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
/**
* Customer attributes
*/
/** @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);
/**
* Create customer attribute account_approve
*/
$customerSetup->addAttribute(Customer::ENTITY, self::APPROVE_ACCOUNT,
[
'type' => 'int',
'label' => 'Approve Account',
'input' => 'select',
"source" => "RBC\Customersegment\Model\Config\Source\CustomerYesNoOptions",
'required' => false,
'default' => '1',
'visible' => true,
'user_defined' => true,
'sort_order' => 215,
'position' => 215,
'system' => false,
]);
$approve_account = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, self::APPROVE_ACCOUNT)
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_account_create','customer_account_edit'],
]);
$approve_account->save();
$setup->endSetup();
}
-
If you want to create YES/NO options for customer, then you need to used boolean attribute.Dhiren Vasoya– Dhiren Vasoya2018年09月11日 14:11:35 +00:00Commented Sep 11, 2018 at 14:11
-
@DhirenVasoya thanks i was also tried with Boolean attribute still getting issue while export customer. my question is there any missing or wrong code? why i am getting error while export customer.Chirag Patel– Chirag Patel2018年09月12日 04:53:35 +00:00Commented Sep 12, 2018 at 4:53
-
1Facing the same issue, let me know if you find anythingAditya Shah– Aditya Shah2018年09月12日 05:00:58 +00:00Commented Sep 12, 2018 at 5:00
1 Answer 1
I have tried the below code with static datatype but it has consequences as mentioned below:
$customerSetup->addAttribute(Customer::ENTITY, self::APPROVE_ACCOUNT,
[
'type' => 'static',
'label' => 'Approve Account',
'input' => 'select',
"source" => "RBC\Customersegment\Model\Config\Source\CustomerYesNoOptions",
'required' => false,
'default' => '1',
'visible' => true,
'user_defined' => true,
'sort_order' => 215,
'position' => 215,
'system' => false,
]);
Using static datatype in attribute will solve the problem in grid export but will throw error while reindexing as the the attribute type is static, it will look into customer_entity table for this field which you might not have created. So in your case, you can follow the suggestions as mentioned below.
It seems that you have not created field in customer_entity table, you are using attribute here, so make sure you have not added field in customer_listing layout in ui_component directory. Also you don't have to add the field in indexer.xml as for attributes, it automatically updates data in customer_grid_flat table.
I hope this helps you with your problem.
-
Thanks man it working fine! :), you are right i was checked there is no attribute data type is int.Chirag Patel– Chirag Patel2018年09月12日 10:02:52 +00:00Commented Sep 12, 2018 at 10:02
-
@Chirag: I have update my answer, the problem was not the datatype but the other things as mentioned in my answer.Sanjay Chaudhary– Sanjay Chaudhary2018年09月12日 13:49:43 +00:00Commented Sep 12, 2018 at 13:49
-
@ChiragPatel I do have the same issue , when i take the export csv this error occurs with my custom attributes, how can i solve this other than making static?Naveenbos– Naveenbos2018年12月04日 11:33:56 +00:00Commented Dec 4, 2018 at 11:33
Explore related questions
See similar questions with these tags.