Coder Social home page Coder Social logo

customer-chooser's Introduction

Magento2 Module Customer Selector In Ui Component Form

How to get it

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

How to use it

  • Multiselect
        <field name="customer">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" translate="true" xsi:type="string">Customer</item>
                    <item name="formElement" xsi:type="string">select</item>
                    <item name="source" xsi:type="string">order_information</item>
                    <item name="dataScope" xsi:type="string">customer</item>
                    <item name="elementTmpl" xsi:type="string">Loyalty_PointsMall/form/element/tonyselect</item>
                    <item name="component" xsi:type="string">Loyalty_PointsMall/js/form/element/tonyselect</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                        <item name="validate-number" xsi:type="boolean">true</item>
                    </item>
                    <item name="tonyselect" xsi:type="array">
                        <item name="maximumSelectionLength" xsi:type="string">1</item>
                        <item name="tags" xsi:type="string">true</item>
                        <item name="ajax" xsi:type="array">
                            <item name="url" xsi:type="string">/admin/loyaltymall/ajax_customer/search</item>
                            <item name="search" xsi:type="string">CustomerSearch</item> <!-- Uses virtual model productsearch -->
                        </item>
                    </item>
                </item>
            </argument>
        </field>
  • di.xml
    <virtualType name="Loyalty\PointsMall\Model\Virtual\CustomerSearch" type="Loyalty\PointsMall\Model\Customer\Search">
        <arguments>
            <argument name="searchData" xsi:type="array">
                <item name="modelCollectionClass" xsi:type="string">Magento\Customer\Model\ResourceModel\Customer\Collection</item>
                <item name="modelClass" xsi:type="string">Magento\Customer\Model\Customer</item>
                <item name="searchFields" xsi:type="array">
                    <item name="firstname" xsi:type="string">firstname</item>
                    <item name="lastname" xsi:type="string">lastname</item>
                </item>
                <item name="modelType" xsi:type="string">eav</item>
                <item name="modelKey" xsi:type="string">entity_id</item>
                <item name="sortByAttribute" xsi:type="string">name</item>
            </argument>
        </arguments>
    </virtualType>

Alt text


Alt text

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

Alt text

customer-chooser's People

Stargazers

Tony Liu avatar

Watchers

James Cloos avatar Tony Liu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.