magento2 customer selector

2018-05-19 01:04:04   Magento

  Magento 2  

Magento2 Module Customer Selector In Ui Component Form

How to get it

  • Use Composer
  1. composer require tony-blog/magento2-customer-selector
  • Use git
  1. git clone https://code.aliyun.com/tony.liu/customer-chooser.git

How to use it

  • Multiselect
  1. <field name="customer">
  2. <argument name="data" xsi:type="array">
  3. <item name="config" xsi:type="array">
  4. <item name="dataType" xsi:type="string">text</item>
  5. <item name="label" translate="true" xsi:type="string">Customer</item>
  6. <item name="formElement" xsi:type="string">select</item>
  7. <item name="source" xsi:type="string">order_information</item>
  8. <item name="dataScope" xsi:type="string">customer</item>
  9. <item name="elementTmpl" xsi:type="string">Loyalty_PointsMall/form/element/tonyselect</item>
  10. <item name="component" xsi:type="string">Loyalty_PointsMall/js/form/element/tonyselect</item>
  11. <item name="validation" xsi:type="array">
  12. <item name="required-entry" xsi:type="boolean">true</item>
  13. <item name="validate-number" xsi:type="boolean">true</item>
  14. </item>
  15. <item name="tonyselect" xsi:type="array">
  16. <item name="maximumSelectionLength" xsi:type="string">1</item>
  17. <item name="tags" xsi:type="string">true</item>
  18. <item name="ajax" xsi:type="array">
  19. <item name="url" xsi:type="string">/admin/loyaltymall/ajax_customer/search</item>
  20. <item name="search" xsi:type="string">CustomerSearch</item> <!-- Uses virtual model productsearch -->
  21. </item>
  22. </item>
  23. </item>
  24. </argument>
  25. </field>
  • di.xml
  1. <virtualType name="Loyalty\PointsMall\Model\Virtual\CustomerSearch" type="Loyalty\PointsMall\Model\Customer\Search">
  2. <arguments>
  3. <argument name="searchData" xsi:type="array">
  4. <item name="modelCollectionClass" xsi:type="string">Magento\Customer\Model\ResourceModel\Customer\Collection</item>
  5. <item name="modelClass" xsi:type="string">Magento\Customer\Model\Customer</item>
  6. <item name="searchFields" xsi:type="array">
  7. <item name="firstname" xsi:type="string">firstname</item>
  8. <item name="lastname" xsi:type="string">lastname</item>
  9. </item>
  10. <item name="modelType" xsi:type="string">eav</item>
  11. <item name="modelKey" xsi:type="string">entity_id</item>
  12. <item name="sortByAttribute" xsi:type="string">name</item>
  13. </argument>
  14. </arguments>
  15. </virtualType>

Alt text


Alt text

More Information, Please Subscribe My Wechat Public Platform Or View My Blog : https://www.abmbio.xin

Alt text