magento 2에서 고객 모듈과 같은 직원 모듈 만들기


15

직원 모듈을 만들었습니다. 고객 모듈과 동일합니다. 에서 모든 파일을에서 복사 vendor/magento/module-customer했습니다 app/code/Magento/Employee. 고객직원으로 교체했습니다 . 그러나 오류가 표시됩니다.

메시지 'Constant name이 (가)있는'InvalidArgumentException '

[InvalidArgumentException]
"setup"네임 스페이스에 정의 된 명령이 없습니다.

내가 module.xml있는 app/Code/Magento/Employee/etc폴더

<?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>

누구든지 어떻게 해결할 수 있습니까?

di.xml

<?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>

음 ... 네 그렇게 쉽지 않을 것입니다. 정확히 무엇을 꺼내려고합니까? 사용자 정의 ORM 모델 및 모듈로 빌드해야합니다.
Ryan Hoerr

Customer 모듈 과 동일한 Employee 모듈 을 만들려고 합니다
mr. 최대

답변:


5

나는이 상수를 di.xml다음 과 같이 생각한다 .

Magento\Employee\Api\EmployeeMetadataInterface::ENTITY_TYPE_Employee

해야한다

Magento\Employee\Api\EmployeeMetadataInterface::ENTITY_TYPE_EMPLOYEE

3

Mr.max,

여기 당신을위한 해결책이 있습니다 :

  1. 소문자와 대문자를 고려하여 파일을 교체했는지 확인하십시오 ( "고객"-> "직원", "고객"-> "직원"등).
  2. "고객"단어가있는 파일 이름 및 폴더 이름을 변경했는지 확인하십시오.
  3. 다른 단어 "고객"을 변경하지 않았는지 확인하십시오. 예를 들어 파일에서

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

    코드가있다

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

    즉,이 방법 subscribeCustomerById은 "모듈 뉴스 레터"모듈 ( Magento\Newsletter\Model\Subscriber) 에서 호출됩니다 . 이름을로 변경 subscribeEmployeeById하면 오류가 발생합니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.