Skip to content
Advertisement

does not extend MagentoFrameworkDataObject

I have exception when I ceate model.Here is that exception:

1 exception(s):
Exception #0 (InvalidArgumentException): Training4VendorModelTraining4_Vendor2Product does not extend MagentoFrameworkDataObject

Exception #0 (InvalidArgumentException): Training4VendorModelTraining4_Vendor2Product does not extend MagentoFrameworkDataObject

Magento version is 2.4.4 Training4VendorModelTraining4_Vendor2Product

<?php


namespace Training4VendorModel;


use MagentoFrameworkModelAbstractModel;

class Training4_Vendor2Product extends AbstractModel
{
    const vendor_id='id';

    protected $_idFieldName  = self::vendor_id;

    protected function _construct()
    {
        $this->_init(Training4VendorModelResourceModelTraining4_Vendor2Product::class);
    }
}

Training4VendorModelResourceModelTraining4_Vendor2Product

<?php


namespace Training4VendorModelResourceModel;


use MagentoFrameworkModelResourceModelDbAbstractDb;

class Training4_Vendor2Product extends AbstractDb
{

    protected function _construct()
    {
        $this->_init('training4_vendor2product','id');
    }
}

Training4VendorModelResourceModelTraining4_Vendor2ProductCollection

<?php


namespace Training4VendorModelResourceModelTraining4_Vendor2Product;


use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;

class Collection extends AbstractCollection
{
    protected $_idFieldName = 'id';

    protected function _construct()
    {
        $this->_init(Training4VendorModelTraining4_Vendor2Product::class,
            Training4VendorModelResourceModelTraining4_Vendor2Product::class);
    }
}

in Training4VendorModelTraining4_Vendor2Product,I have already extends MagentoFrameworkModelAbstractModel,I don’t know why that exception occur

Advertisement

Answer

did you add dependency in di.xml

<virtualType name="HelenOfTroyWebinarModelResourceModelSpecificSpeakersGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
    <arguments>
        <argument name="mainTable" xsi:type="string">training4_vendor2product</argument>
        <argument name="resourceModel" xsi:type="string">Training4VendorModelResourceModelTraining4_Vendor2Product</argument>
    </arguments>
</virtualType>
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement