2

I have uploaded the extension in the marketplace, but it's failed in the enterprise edition. There is no issue in the community version.

I have tried to resolve the error by clearing var/generation folder and running php bin/magento setup:di:compile command but it's not working.

Error

Review Results:

Test environments Used: 
Magento 2.3.5 Enterprise Edition (PHP 7.3.17)
Magento ver. 2.2.11 Enterprise Edition (PHP 7.2.30)

Report:-

[2020-06-23 09:46:37] report.CRITICAL: Type Error occurred when creating object: Myvendor\GiftCard\Model\ResourceModel\Templates\Collection\Interceptor, Argument 5 passed to Myvendor\GiftCard\Model\ResourceModel\Templates\Collection\Interceptor::__construct() must implement interface Magento\Framework\DB\Adapter\AdapterInterface or be null, string given, called in /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 [] [] [2020-06-23 09:46:37] report.CRITICAL: Type Error occurred when creating object: Myvendor\GiftCard\Model\ResourceModel\Templates\Collection\Interceptor [] []

Myvendor\GiftCard\Model\ResourceModel\Templates\Collection.php

<?php
    
    namespace Myvendor\GiftCard\Model\ResourceModel\Templates;
    
    /**
     * Templates model collection
     */
    class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
    {
        
        /**
         * init constructor
         */
        protected function _construct()
        {
            $this->_init(
                \Myvendor\GiftCard\Model\Templates::class,
                \Myvendor\GiftCard\Model\ResourceModel\Templates::class
            );
        }
    }

Myvendor\GiftCard\etc\di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="TemplateGirdFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
        <arguments>
            <argument name="appliers" xsi:type="array">
                <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
                <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
            </argument>
        </arguments>
    </virtualType>   
   <virtualType name="TemplateGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Myvendor\GiftCard\Model\ResourceModel\Templates\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">TemplateGirdFilterPool</argument>
        </arguments>
    </virtualType>
    <virtualType name="Myvendor\GiftCard\Model\ResourceModel\Templates\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">gift_templates</argument>
            <argument name="resourceModel" xsi:type="string">Myvendor\GiftCard\Model\ResourceModel\Templates</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="rocktech_giftcard_data_source" xsi:type="string">Myvendor\GiftCard\Model\ResourceModel\Templates\Collection</item>
            </argument>
        </arguments>
    </type> 
    <virtualType name="CodeSetGridFilter" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
        <arguments>
            <argument name="appliers" xsi:type="array">
                <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
                <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
            </argument>
        </arguments>
    </virtualType>   
    <virtualType name="CodesetProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Myvendor\GiftCard\Model\ResourceModel\Codeset\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">CodeSetGridFilter</argument>
        </arguments>
    </virtualType>
    <virtualType name="Myvendor\GiftCard\Model\ResourceModel\Codeset\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">gift_code_set</argument>
            <argument name="resourceModel" xsi:type="string">Myvendor\GiftCard\Model\ResourceModel\Codeset</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="rocktech_codeset_datasource" xsi:type="string">Myvendor\GiftCard\Model\ResourceModel\Codeset\Collection</item>
            </argument>
        </arguments>
    </type> 
    <virtualType name="AccountGridFilter" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
        <arguments>
            <argument name="appliers" xsi:type="array">
                <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
                <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
            </argument>
        </arguments>
    </virtualType>   
   <virtualType name="CodesetProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
        <arguments>
            <argument name="collection" xsi:type="object" shared="false">Myvendor\GiftCard\Model\ResourceModel\Account\Collection</argument>
            <argument name="filterPool" xsi:type="object" shared="false">AccountGridFilter</argument>
        </arguments>
    </virtualType>
    <virtualType name="Myvendor\GiftCard\Model\ResourceModel\Account\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">gift_code_account</argument>
            <argument name="resourceModel" xsi:type="string">Myvendor\GiftCard\Model\ResourceModel\Account</argument>
        </arguments>
    </virtualType>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="account_dataset" xsi:type="string">Myvendor\GiftCard\Model\ResourceModel\Account\Collection</item>
            </argument>
        </arguments>
    </type>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="form_data" xsi:type="string">EntityItemGridCollection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="EntityItemGridCollection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">gift_templates</argument>
            <argument name="resourceModel" xsi:type="string">Myvendor\GiftCard\Model\ResourceModel\Templates</argument>
        </arguments>
    </virtualType>
    <preference for="Magento\Catalog\Model\Design" type="Myvendor\GiftCard\Model\Design" /> 
    <preference for="Magento\Checkout\Controller\Cart\Configure" type="Myvendor\GiftCard\Controller\Cart\Configure" />   
     <type name="Magento\Customer\Api\AccountManagementInterface">
        <plugin name="check_customer_for_GiftCard" type="Myvendor\GiftCard\Plugin\AccountManagement" />
    </type>
    <preference for="Magento\Quote\Model\PaymentMethodManagement" type="Myvendor\GiftCard\Model\PaymentMethodManagement" /> 
    <preference for="Magento\Sales\Block\Order\Totals" type="Myvendor\GiftCard\Block\Giftorder\Totals" />    
    <preference for="Myvendor\GiftCard\Api\GiftCardManagementInterface" type="Myvendor\GiftCard\Model\GiftCardManagement" />
</config>

If Anyone has any ideas, please let me know.

5
  • Show your di.xml – Sohel Rana Jun 27 '20 at 8:02
  • updated a question, please check. – Mohit Rane Jun 27 '20 at 9:21
  • @SohelRana do you have any suggestions? – Mohit Rane Jul 2 '20 at 10:16
  • I am going through the same issue, help ! – Gustavo Ulyssea Aug 24 '20 at 21:32
  • @GustavoUlyssea I haven't found the solution yet – Mohit Rane Aug 25 '20 at 5:29
1

This answer helped me to fix the issue, it appears that the virtual type collection name has to be different than the class namespace - https://magento.stackexchange.com/a/290477

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.