Tạo mô đun nhân viên giống như mô đun khách hàng trong magento 2


15

Tôi đã tạo mô-đun Nhân viên. giống như mô-đun khách hàng. tôi đã sao chép tất cả các tập tin từ vendor/magento/module-customerđến app/code/Magento/Employee. Tôi đã thay thế khách hàng bằng nhân viên . nhưng nó hiển thị một lỗi:

'UnlimitedArgumentException' với thông báo 'Tên liên tục được mong đợi.

[UnlimitedArgumentException]
Không có lệnh nào được xác định trong không gian tên "setup".

Của tôi module.xmltrong app/Code/Magento/Employee/etcthư mục

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Employee" setup_version="2.0.6">
    <sequence>
        <module name="Magento_Eav"/>
        <module name="Magento_Directory"/>
    </sequence>
</module>
</config>

Xin vui lòng cho tôi biết làm thế nào tôi có thể giải quyết nó?

Di.xml của tôi

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Employee\Api\AddressRepositoryInterface"
                type="Magento\Employee\Model\ResourceModel\AddressRepository" />
    <preference for="Magento\Employee\Api\EmployeeRepositoryInterface"
                type="Magento\Employee\Model\ResourceModel\EmployeeRepository" />
    <preference for="Magento\Employee\Api\GroupManagementInterface"
                type="Magento\Employee\Model\GroupManagement" />
    <preference for="Magento\Employee\Api\GroupRepositoryInterface"
                type="Magento\Employee\Model\ResourceModel\GroupRepository" />
    <preference for="Magento\Employee\Api\Data\EmployeeInterface" type="Magento\Employee\Model\Data\Employee" />
    <preference for="Magento\Employee\Api\Data\AddressInterface" type="Magento\Employee\Model\Data\Address" />
    <preference for="Magento\Employee\Api\Data\RegionInterface" type="Magento\Employee\Model\Data\Region" />
    <preference for="Magento\Employee\Api\Data\AttributeMetadataInterface"
                type="Magento\Employee\Model\Data\AttributeMetadata" />
    <preference for="Magento\Employee\Api\Data\GroupInterface" type="Magento\Employee\Model\Data\Group" />
    <preference for="Magento\Employee\Api\Data\OptionInterface" type="Magento\Employee\Model\Data\Option" />
    <preference for="Magento\Employee\Api\Data\ValidationRuleInterface"
                type="Magento\Employee\Model\Data\ValidationRule" />
    <preference for="Magento\Employee\Api\Data\ValidationResultsInterface"
                type="Magento\Employee\Model\Data\ValidationResults" />
    <preference for="Magento\Employee\Api\Data\GroupSearchResultsInterface"
                type="Magento\Framework\Api\SearchResults" />
    <preference for="Magento\Employee\Api\Data\EmployeeSearchResultsInterface"
                type="Magento\Framework\Api\SearchResults" />
    <preference for="Magento\Employee\Api\Data\AddressSearchResultsInterface"
                type="Magento\Framework\Api\SearchResults" />
    <preference for="Magento\Employee\Api\AccountManagementInterface"
                type="Magento\Employee\Model\AccountManagement" />
    <preference for="Magento\Employee\Api\EmployeeMetadataInterface"
                type="Magento\Employee\Model\Metadata\EmployeeCachedMetadata" />
    <preference for="Magento\Employee\Api\AddressMetadataInterface"
                type="Magento\Employee\Model\Metadata\AddressCachedMetadata" />
    <preference for="Magento\Employee\Api\EmployeeMetadataManagementInterface"
                type="Magento\Employee\Model\Metadata\EmployeeMetadataManagement" />
    <preference for="Magento\Employee\Api\AddressMetadataManagementInterface"
                type="Magento\Employee\Model\Metadata\AddressMetadataManagement" />
    <preference for="Magento\Employee\Api\EmployeeManagementInterface"
                type="Magento\Employee\Model\EmployeeManagement" />
    <type name="Magento\Employee\Model\EmployeeSession">
    <arguments>
        <argument name="configShare" xsi:type="object">Magento\Employee\Model\Config\Share\Proxy</argument>
        <argument name="employeeUrl" xsi:type="object">Magento\Employee\Model\Url\Proxy</argument>
        <argument name="employeeResource" xsi:type="object">Magento\Employee\Model\ResourceModel\Employee\Proxy</argument>
        <argument name="storage" xsi:type="object">Magento\Employee\Model\Session\Storage</argument>
        <argument name="employeeRepository" xsi:type="object">Magento\Employee\Api\EmployeeRepositoryInterface\Proxy</argument>
    </arguments>
</type>
    <type name="Magento\Employee\Helper\Address">
        <arguments>
            <argument name="addressConfig" xsi:type="object">Magento\Employee\Model\Address\Config\Proxy</argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\Config\Share">
        <arguments>
            <argument name="employeeResource" xsi:type="object">Magento\Employee\Model\ResourceModel\Employee\Proxy</argument>
        </arguments>
    </type>
    <type name="Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite">
        <arguments>
            <argument name="propertyMappers" xsi:type="array">
                <item name="employee" xsi:type="string">Magento\Employee\Model\ResourceModel\Setup\PropertyMapper</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Framework\Model\ActionValidator\RemoveAction">
        <arguments>
            <argument name="protectedModels" xsi:type="array">
                <item name="employee" xsi:type="string">Magento\Employee\Model\Employee</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\ResourceModel\Address">
        <arguments>
            <argument name="employeeRepository" xsi:type="object">Magento\Employee\Api\EmployeeRepositoryInterface\Proxy</argument>
            <argument name="entitySnapshot" xsi:type="object">EavVersionControlSnapshot</argument>
            <argument name="entityRelationComposite" xsi:type="object">EmployeeAddressRelationsComposite</argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\Address\Config">
        <arguments>
            <argument name="reader" xsi:type="object">Magento\Employee\Model\Address\Config\Reader\Proxy</argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\Visitor">
        <arguments>
            <argument name="ignoredUserAgents" xsi:type="array">
                <item name="google1" xsi:type="string">Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/)</item>
                <item name="google2" xsi:type="string">Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</item>
                <item name="google3" xsi:type="string">Googlebot/2.1 (+http://www.googlebot.com/bot.html)</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\ResourceModel\Group" shared="false">
        <arguments>
            <argument name="groupManagement" xsi:type="object">Magento\Employee\Api\GroupManagementInterface\Proxy</argument>
        </arguments>
    </type>
    <virtualType name="SectionInvalidationConfigReader" type="Magento\Framework\Config\Reader\Filesystem">
        <arguments>
            <argument name="idAttributes" xsi:type="array">
                <item name="/config/action" xsi:type="string">name</item>
                <item name="/config/action/section" xsi:type="string">name</item>
            </argument>
            <argument name="fileName" xsi:type="string">sections.xml</argument>
            <argument name="converter" xsi:type="object">\Magento\Employee\EmployeeData\SectionConfigConverter</argument>
            <argument name="schemaLocator" xsi:type="object">Magento\Employee\EmployeeData\SchemaLocator</argument>
            <argument name="defaultScope" xsi:type="string">frontend</argument>
        </arguments>
    </virtualType>
    <virtualType name="SectionInvalidationConfigData" type="Magento\Framework\Config\Data">
        <arguments>
            <argument name="reader" xsi:type="object">SectionInvalidationConfigReader</argument>
            <argument name="cacheId" xsi:type="string">sections_invalidation_config</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Employee\Block\SectionConfig">
        <arguments>
            <argument name="sectionConfig" xsi:type="object">SectionInvalidationConfigData</argument>
        </arguments>
    </type>
    <type name="Magento\Eav\Model\EavCustomAttributeTypeLocator">
        <arguments>
            <argument name="serviceEntityTypeMap" xsi:type="array">
                <item name="Magento\Employee\Api\Data\EmployeeInterface" xsi:type="const">Magento\Employee\Api\EmployeeMetadataInterface::ENTITY_TYPE_Employee</item>
            </argument>
            <argument name="serviceBackendModelDataInterfaceMap" xsi:type="array">
                <item name="Magento\Employee\Api\Data\EmployeeInterface" xsi:type="array">
                    <item name="Magento\Eav\Model\Attribute\Data\Image" xsi:type="string">Magento\Framework\Api\Data\ImageContentInterface</item>
                </item>
            </argument>
        </arguments>
    </type>
    <virtualType name="EavVersionControlSnapshot" type="Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot">
        <arguments>
            <argument name="metadata" xsi:type="object">Magento\Eav\Model\Entity\VersionControl\Metadata</argument>
        </arguments>
    </virtualType>
    <virtualType name="EmployeeRelationsComposite" type="Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite">
        <arguments>
            <argument name="relationProcessors" xsi:type="array">
                <item name="default" xsi:type="object">Magento\Employee\Model\ResourceModel\Employee\Relation</item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="EmployeeAddressRelationsComposite" type="Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite">
        <arguments>
            <argument name="relationProcessors" xsi:type="array">
                <item name="default" xsi:type="object">Magento\Employee\Model\ResourceModel\Address\Relation</item>
            </argument>
        </arguments>
    </virtualType>
    <type name="Magento\Employee\Model\ResourceModel\Employee">
        <arguments>
            <argument name="entitySnapshot" xsi:type="object">EavVersionControlSnapshot</argument>
            <argument name="entityRelationComposite" xsi:type="object">EmployeeRelationsComposite</argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\ResourceModel\Employee\Collection">
        <arguments>
            <argument name="entitySnapshot" xsi:type="object">EavVersionControlSnapshot</argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\ResourceModel\Address\Collection">
        <arguments>
            <argument name="entitySnapshot" xsi:type="object">EavVersionControlSnapshot</argument>
        </arguments>
    </type>
    <virtualType name="Magento\Employee\Model\ResourceModel\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">employee_grid_flat</argument>
            <argument name="resourceModel" xsi:type="string">Magento\Employee\Model\ResourceModel\Employee</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="employee_listing_data_source" xsi:type="string">Magento\Employee\Model\ResourceModel\Grid\Collection</item>
                <item name="employee_online_grid_data_source" xsi:type="string">Magento\Employee\Model\ResourceModel\Online\Grid\Collection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="EmployeeNameHandler" type="Magento\Framework\Indexer\Handler\ConcatHandler">
        <arguments>
            <argument name="concatExpression" xsi:type="object">EmployeeNameExpression</argument>
        </arguments>
    </virtualType>
    <virtualType name="ShippingAddressHandler" type="Magento\Framework\Indexer\Handler\ConcatHandler">
        <arguments>
            <argument name="concatExpression" xsi:type="object">ShippingAddressExpression</argument>
        </arguments>
    </virtualType>
    <virtualType name="BillingAddressHandler" type="Magento\Framework\Indexer\Handler\ConcatHandler">
        <arguments>
            <argument name="concatExpression" xsi:type="object">BillingAddressExpression</argument>
        </arguments>
    </virtualType>
    <virtualType name="LastVisitAtHandler" type="Magento\Framework\Indexer\Handler\ConcatHandler">
        <arguments>
            <argument name="concatExpression" xsi:type="object">LastVisitAtSubSelect</argument>
        </arguments>
    </virtualType>
    <virtualType name="LastVisitAtSubSelect" type="Magento\Framework\DB\Sql\LookupExpression">
        <arguments>
            <argument name="targetTable" xsi:type="string">employee_visitor</argument>
            <argument name="targetColumn" xsi:type="string">last_visit_at</argument>
            <argument name="referenceColumns" xsi:type="array">
                <item name="employee_id" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">e</item>
                    <item name="columnName" xsi:type="string">entity_id</item>
                </item>
            </argument>
            <argument name="sortOrder" xsi:type="array">
                <item name="DESC" xsi:type="string">last_visit_at</item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="EmployeeNameExpression" type="Magento\Framework\DB\Sql\ConcatExpression">
        <arguments>
            <argument name="tableName" xsi:type="string">e</argument>
            <argument name="columns" xsi:type="array">
                <item name="prefix" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">e</item>
                    <item name="columnName" xsi:type="string">prefix</item>
                </item>
                <item name="firstname" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">e</item>
                    <item name="columnName" xsi:type="string">firstname</item>
                </item>
                <item name="middlename" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">e</item>
                    <item name="columnName" xsi:type="string">middlename</item>
                </item>
                <item name="lastname" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">e</item>
                    <item name="columnName" xsi:type="string">lastname</item>
                </item>
                <item name="suffix" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">e</item>
                    <item name="columnName" xsi:type="string">suffix</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="ShippingAddressExpression" type="Magento\Framework\DB\Sql\ConcatExpression">
        <arguments>
            <argument name="columns" xsi:type="array">
                <item name="prefix" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">shipping</item>
                    <item name="columnName" xsi:type="string">street</item>
                </item>
                <item name="firstname" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">shipping</item>
                    <item name="columnName" xsi:type="string">city</item>
                </item>
                <item name="middlename" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">shipping</item>
                    <item name="columnName" xsi:type="string">region</item>
                </item>
                <item name="lastname" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">shipping</item>
                    <item name="columnName" xsi:type="string">postcode</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="BillingAddressExpression" type="Magento\Framework\DB\Sql\ConcatExpression">
        <arguments>
            <argument name="columns" xsi:type="array">
                <item name="prefix" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">billing</item>
                    <item name="columnName" xsi:type="string">street</item>
                </item>
                <item name="firstname" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">billing</item>
                    <item name="columnName" xsi:type="string">city</item>
                </item>
                <item name="middlename" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">billing</item>
                    <item name="columnName" xsi:type="string">region</item>
                </item>
                <item name="lastname" xsi:type="array">
                    <item name="tableAlias" xsi:type="string">billing</item>
                    <item name="columnName" xsi:type="string">postcode</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
    <type name="Magento\Employee\Model\Indexer\AttributeProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Magento\Employee\Model\ResourceModel\Attribute\Collection</argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\Indexer\Address\AttributeProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Magento\Employee\Model\ResourceModel\Address\Attribute\Collection</argument>
        </arguments>
    </type>
    <type name="Magento\Employee\Model\ResourceModel\Online\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">employee_visitor</argument>
            <argument name="resourceModel" xsi:type="string">Magento\Employee\Model\ResourceModel\Visitor</argument>
        </arguments>
    </type>
</config>

Ừm ... ừ. Điều đó sẽ không dễ dàng như vậy. Chính xác thì bạn đang cố gắng thoát ra điều gì? Bạn nên xây dựng nó như một mô hình và mô-đun ORM tùy chỉnh.
Ryan Hoerr

tôi đang cố gắng tạo mô-đun Nhân viên giống như mô-đun Khách hàng
ông. tối đa

Câu trả lời:


5

Tôi nghĩ rằng điều này liên tục trong di.xml:

Magento\Employee\Api\EmployeeMetadataInterface::ENTITY_TYPE_Employee

nên là

Magento\Employee\Api\EmployeeMetadataInterface::ENTITY_TYPE_EMPLOYEE

3

mr.max,

Đây là một giải pháp cho bạn:

  1. Kiểm tra, nếu bạn thay thế các tệp có tính đến chữ thường và chữ in hoa ("khách hàng" -> "nhân viên", "Khách hàng" -> "Nhân viên", v.v.)
  2. Kiểm tra, nếu bạn thay đổi tên tệp và tên thư mục, nơi có từ "Khách hàng".
  3. Hãy chắc chắn rằng bạn đã không thay đổi bất kỳ từ nào khác "Khách hàng". Ví dụ: trong tệp

    vendor/magento/module-customer/Controller/Adminhtml/Index/MassSubscribe.php

    có một mã

    $this->subscriberFactory->create()->subscribeCustomerById($customerId);

    Điều đó có nghĩa là phương thức subscribeCustomerByIdnày được gọi từ mô-đun "mô-đun bản tin" ( Magento\Newsletter\Model\Subscriber). Và nếu bạn đổi tên thành subscribeEmployeeById, bạn sẽ gặp lỗi.

Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookieChính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.