Filter customer collection by custom attribute in magento 2

I created a custom attribute for customer and would like to filter my collection through it.

My UpgradeData:

if (version_compare($  context->getVersion(), '1.0.6', '<')) {      $  attributesInfo = [         'celular'  => [         'label'    => 'Celular',         'type'     => 'varchar', // can be static too         'input'    => 'text',         'unique' => true,         'position' => 90,         'visible'  => true,         'required' => true,         'system'   => 0, // Important otherwise attribute is not seen as custom attribute     ], ];      foreach ($  attributesInfo as $  attributeCode => $  attributeParams) {         $  customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, $  attributeCode, $  attributeParams);     }      foreach ($  attributesInfo as $  attributeCode => $  attributeParams) {          $  attribute = $  customerSetup->getEavConfig()->getAttribute(\Magento\Customer\Model\Customer::ENTITY, $  attributeCode);         $  attribute->setData(             'used_in_forms',             ['adminhtml_customer']         );         $  attribute->save();     } } 

My Collection:

$  objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $  customerObj = $  objectManager->create('Magento\Customer\Model\ResourceModel\Customer\Collection');          $  customer = $  customerObj->addAttributeToSelect('*')         ->addAttributeToFilter('celular',$  username)         ->load()->getData(); 

Even though I am attaching a value to this field, no customer is found, what should I do?


Images database: eav_attribute


My main objective is: Distribute the highest level of customer satisfaction. for $5

I assure you of 100% quality work. I can deliver high-accuracy and timely deliveries along with any kind of typing related work and copy paste data, PDF conversions I want to build those customers who can trust me on a regular basis, who need expertise in my time management. To acquire and learn new skills that will be beneficial for my client projects.

by: Manoj82
Created: —
Category: Data Entry
Viewed: 91

Customer Address Edit form

I want to add only Nigeria as the option in Country Dropdown, and the nigerian states in the states/province dropdown. How to do that. I tried something through Admin panel, when i found these issues when i select US and nigeria and shown in the below screenshot.

How to avoid this? I want only nigerian states to be in the dropdown.

Magento 2: how to enable and disable customer?

I am looking for code how the customer can be enabled and disabled using customer Id in Magento 2.

When customer is disabled we should not allow customer to login from front end.

I tried setting is_active column as 0 in Database then also i can able to login from frontend.

I am using below code

  public function execute(){      $  user = $  this->customerFactory->create();         $  userId = $  this->getRequest()->getParam('user_id', false);         $  status = 0;         if($  userId):           $  user->load($  userId)->setWebsiteId($  oldUser->getWebsiteId());               endif;       try {                  $  user->setIsActive($  status);             $  user->save();            }catch (\Exception $  e){            $  this->_messageManager->addError(__('Can\'t save user'));          }   } 

is that can be done pro grammatically?

Customer Document Libary: How to organize a libary to store information effectively?

I need to create a list to contain information about customers and a library to contain document relate to these customers.
A customer List Column:

  • Customer Name
  • Customer ID

A Document List: Can I create a folder for each Customer?

  • Folder columns: Customer Name, Customer ID
  • File in Folder Property: Customer Name, Customer ID, Product Buy, Sale Order Number… (The names of documents between clients may be the same)

Is such a list system effective?