Tweeted twitter.com/StackMagento/status/890757763634257922
4 deleted 1 character in body; edited tags
source | link

Playing around with Magento 2 but run into a problem I can not wrap my head around. The object manager tries to instantiate Abstract class, this gives an Fatal Error. Does someone know what might cause this or point me in the right direction?

The Error

Fatal error: Cannot instantiate abstract class Magento\Framework\Model\Resource\AbstractResource in /lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php on line 75

The Problem

My module has a model that extends the \Magento\Quote\Model\Quote. The constructor of this model has the following line injecting this:

\Magento\Framework\Model\Resource\AbstractResource $resource = null,.

The controller that is instantiating the model extends the \Magento\Backend\App\Action and uses $this->_objectManager->create() to instantiate the model.

The thing I can not wrap my head around is, if I instantiate the Magento model it just works but if I instantiate my model it tries to instantiate this abstract class throwing the error above. What tells the object manager to do this and how can I solve my problem?

My first thought was Magento uses the di.xml to replace this, execute this or something, this was not the case.

Thanks for taking the time to read this. Any help or input on this issue is appreciated.

Playing around with Magento 2 but run into a problem I can not wrap my head around. The object manager tries to instantiate Abstract class, this gives an Fatal Error. Does someone know what might cause this or point me in the right direction?

The Error

Fatal error: Cannot instantiate abstract class Magento\Framework\Model\Resource\AbstractResource in /lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php on line 75

The Problem

My module has a model that extends the \Magento\Quote\Model\Quote. The constructor of this model has the following line injecting this:

\Magento\Framework\Model\Resource\AbstractResource $resource = null,.

The controller that is instantiating the model extends the \Magento\Backend\App\Action and uses $this->_objectManager->create() to instantiate the model.

The thing I can not wrap my head around is, if I instantiate the Magento model it just works but if I instantiate my model it tries to instantiate this abstract class throwing the error above. What tells the object manager to do this and how can I solve my problem?

My first thought was Magento uses the di.xml to replace this, execute this or something, this was not the case.

Thanks for taking the time to read this. Any help or input on this issue is appreciated.

Playing around with Magento 2 but run into a problem I can not wrap my head around. The object manager tries to instantiate Abstract class, this gives an Fatal Error. Does someone know what might cause this or point me in the right direction?

The Error

Fatal error: Cannot instantiate abstract class Magento\Framework\Model\Resource\AbstractResource in /lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php on line 75

The Problem

My module has a model that extends the \Magento\Quote\Model\Quote. The constructor of this model has the following line injecting this:

\Magento\Framework\Model\Resource\AbstractResource $resource = null,.

The controller that is instantiating the model extends the \Magento\Backend\App\Action and uses $this->_objectManager->create() to instantiate the model.

The thing I can not wrap my head around is if I instantiate the Magento model it just works but if I instantiate my model it tries to instantiate this abstract class throwing the error above. What tells the object manager to do this and how can I solve my problem?

My first thought was Magento uses the di.xml to replace this, execute this or something, this was not the case.

Thanks for taking the time to read this. Any help or input on this issue is appreciated.

3 Made question easier to comprehend
source | link

Additional information ( as requested by Marius )

My quote model:

namespace Rofavadeka\AwesomeModule\Model;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\GroupInterface;
use Magento\Framework\Model\AbstractExtensibleModel;
use Magento\Quote\Api\Data\PaymentInterface;
use Magento\Quote\Model\Quote\Address;
use Magento\Sales\Model\Resource;
use Magento\Sales\Model\Status;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;

class Quote extends \Magento\Quote\Model\Quote
{
/**
 * @var \Magento\Sales\Model\Order\Config
 */
protected $_orderConfig;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory
 */
protected $_quoteHistoryFactory;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory
 */
protected $_historyCollectionFactory;

/**
 * Re-collect quote flag
 *
 * @var boolean
 */
protected $_needCollect;

/**
 * Quote session object
 *
 * @var \Magento\Backend\Model\Session\Quote
 */
protected $_session;

/**
 * @var \Magento\Framework\ObjectManagerInterface
 */
protected $_objectManager;

/**
 * Core registry
 *
 * @var \Magento\Framework\Registry
 */
protected $_coreRegistry = null;

/**
 * @var \Magento\Framework\Message\ManagerInterface
 */
protected $messageManager;

/**
 * @var \Magento\Quote\Model\Quote\Item\Updater
 */
protected $quoteItemUpdater;

/**
 * Quote associated with the model
 *
 * @var \Rofavadeka\AwesomeModule\Model\Quote
 */
protected $_quote;

/**
 * @var \Magento\Quote\Model\QuoteRepository
 */
protected $quoteRepository;

/**
 * @param \Magento\Framework\Model\Context $context
 * @param \Magento\Framework\Registry $registry
 * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
 * @param AttributeValueFactory $customAttributeFactory
 * @param \Magento\Quote\Model\QuoteValidator $quoteValidator
 * @param \Magento\Catalog\Helper\Product $catalogProduct
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
 * @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory
 * @param \Magento\Customer\Model\CustomerFactory $customerFactory
 * @param \Magento\Customer\Api\GroupRepositoryInterface $groupRepository
 * @param \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory
 * @param \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory
 * @param \Magento\Framework\Message\Factory $messageFactory
 * @param Status\ListFactory $statusListFactory
 * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
 * @param \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory
 * @param \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory
 * @param \Magento\Framework\Object\Copy $objectCopyService
 * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
 * @param \Magento\Quote\Model\Quote\Item\Processor $itemProcessor
 * @param \Magento\Framework\Object\Factory $objectFactory
 * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
 * @param \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder
 * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
 * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory
 * @param \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory
 * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
 * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
 * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter
 * @param \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory
 * @param JoinProcessorInterface $extensionAttributesJoinProcessor
 * @param \Magento\Framework\Model\Resource\AbstractResource $resource
 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
 * @param \Magento\Sales\Model\Order\Config $orderConfig
 * @param \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory
 * @param \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory
 * @param \Magento\Framework\ObjectManagerInterface $objectManager
 * @param array $data
 *
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
 */
public function __construct(
    \Magento\Framework\Model\Context $context,
    \Magento\Framework\Registry $registry,
    \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
    AttributeValueFactory $customAttributeFactory,
    \Magento\Quote\Model\QuoteValidator $quoteValidator,
    \Magento\Catalog\Helper\Product $catalogProduct,
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Framework\App\Config\ScopeConfigInterface $config,
    \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
    \Magento\Customer\Model\CustomerFactory $customerFactory,
    \Magento\Customer\Api\GroupRepositoryInterface $groupRepository,
    \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory,
    \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory,
    \Magento\Framework\Message\Factory $messageFactory,
    \Magento\Sales\Model\Status\ListFactory $statusListFactory,
    \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
    \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory,
    \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory,
    \Magento\Framework\Object\Copy $objectCopyService,
    \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
    \Magento\Quote\Model\Quote\Item\Processor $itemProcessor,
    \Magento\Framework\Object\Factory $objectFactory,
    \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
    \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder,
    \Magento\Framework\Api\FilterBuilder $filterBuilder,
    \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory,
    \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory,
    \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
    \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
    \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
    \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory,
    \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
    \Magento\Framework\Model\Resource\AbstractResource $resource = null,
    \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
    \Magento\Sales\Model\Order\Config $orderConfig,
    \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory,
          \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory,
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Backend\Model\Session\Quote $quoteSession,
        \Magento\Framework\Registry $coreRegistry,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Quote\Model\Quote\Item\Updater $quoteItemUpdater,
        \Magento\Quote\Model\QuoteRepository $quoteRepository,
        array $data = []
    ) {
        parent::__construct(
            $context,
            $registry,
            $extensionFactory,
            $customAttributeFactory,
            $quoteValidator,
            $catalogProduct,
            $scopeConfig,
            $storeManager,
            $config,
            $quoteAddressFactory,
            $customerFactory,
            $groupRepository,
            $quoteItemCollectionFactory,
            $quoteItemFactory,
            $messageFactory,
            $statusListFactory,
            $productRepository,
            $quotePaymentFactory,
            $quotePaymentCollectionFactory,
            $objectCopyService,
            $stockRegistry,
            $itemProcessor,
            $objectFactory,
            $addressRepository,
            $criteriaBuilder,
            $filterBuilder,
            $addressDataFactory,
            $customerDataFactory,
            $customerRepository,
            $dataObjectHelper,
            $extensibleDataObjectConverter,
            $currencyFactory,
            $extensionAttributesJoinProcessor,
            $resource,
            $resourceCollection,
            $data
        );
        $this->_orderConfig = $orderConfig;
        $this->_quoteHistoryFactory = $quoteHistoryFactory;
        $this->_historyCollectionFactory = $historyCollectionFactory;
        $this->_objectManager = $objectManager;
        $this->_session = $quoteSession;
        $this->_coreRegistry = $coreRegistry;
        $this->messageManager = $messageManager;
        $this->quoteItemUpdater = $quoteItemUpdater;
        $this->quoteRepository = $quoteRepository;
    }

    /**
    * Init resource model
    *
    * @return void
    */
    protected function _construct()
    {
        $this->_init('Rofavadeka\AwesomeModule\Model\Resource\Quote');
    }
}

Additional information ( as requested by Marius )

My quote model:

namespace Rofavadeka\AwesomeModule\Model;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\GroupInterface;
use Magento\Framework\Model\AbstractExtensibleModel;
use Magento\Quote\Api\Data\PaymentInterface;
use Magento\Quote\Model\Quote\Address;
use Magento\Sales\Model\Resource;
use Magento\Sales\Model\Status;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;

class Quote extends \Magento\Quote\Model\Quote
{
/**
 * @var \Magento\Sales\Model\Order\Config
 */
protected $_orderConfig;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory
 */
protected $_quoteHistoryFactory;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory
 */
protected $_historyCollectionFactory;

/**
 * Re-collect quote flag
 *
 * @var boolean
 */
protected $_needCollect;

/**
 * Quote session object
 *
 * @var \Magento\Backend\Model\Session\Quote
 */
protected $_session;

/**
 * @var \Magento\Framework\ObjectManagerInterface
 */
protected $_objectManager;

/**
 * Core registry
 *
 * @var \Magento\Framework\Registry
 */
protected $_coreRegistry = null;

/**
 * @var \Magento\Framework\Message\ManagerInterface
 */
protected $messageManager;

/**
 * @var \Magento\Quote\Model\Quote\Item\Updater
 */
protected $quoteItemUpdater;

/**
 * Quote associated with the model
 *
 * @var \Rofavadeka\AwesomeModule\Model\Quote
 */
protected $_quote;

/**
 * @var \Magento\Quote\Model\QuoteRepository
 */
protected $quoteRepository;

/**
 * @param \Magento\Framework\Model\Context $context
 * @param \Magento\Framework\Registry $registry
 * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
 * @param AttributeValueFactory $customAttributeFactory
 * @param \Magento\Quote\Model\QuoteValidator $quoteValidator
 * @param \Magento\Catalog\Helper\Product $catalogProduct
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
 * @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory
 * @param \Magento\Customer\Model\CustomerFactory $customerFactory
 * @param \Magento\Customer\Api\GroupRepositoryInterface $groupRepository
 * @param \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory
 * @param \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory
 * @param \Magento\Framework\Message\Factory $messageFactory
 * @param Status\ListFactory $statusListFactory
 * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
 * @param \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory
 * @param \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory
 * @param \Magento\Framework\Object\Copy $objectCopyService
 * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
 * @param \Magento\Quote\Model\Quote\Item\Processor $itemProcessor
 * @param \Magento\Framework\Object\Factory $objectFactory
 * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
 * @param \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder
 * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
 * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory
 * @param \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory
 * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
 * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
 * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter
 * @param \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory
 * @param JoinProcessorInterface $extensionAttributesJoinProcessor
 * @param \Magento\Framework\Model\Resource\AbstractResource $resource
 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
 * @param \Magento\Sales\Model\Order\Config $orderConfig
 * @param \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory
 * @param \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory
 * @param \Magento\Framework\ObjectManagerInterface $objectManager
 * @param array $data
 *
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
 */
public function __construct(
    \Magento\Framework\Model\Context $context,
    \Magento\Framework\Registry $registry,
    \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
    AttributeValueFactory $customAttributeFactory,
    \Magento\Quote\Model\QuoteValidator $quoteValidator,
    \Magento\Catalog\Helper\Product $catalogProduct,
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Framework\App\Config\ScopeConfigInterface $config,
    \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
    \Magento\Customer\Model\CustomerFactory $customerFactory,
    \Magento\Customer\Api\GroupRepositoryInterface $groupRepository,
    \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory,
    \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory,
    \Magento\Framework\Message\Factory $messageFactory,
    \Magento\Sales\Model\Status\ListFactory $statusListFactory,
    \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
    \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory,
    \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory,
    \Magento\Framework\Object\Copy $objectCopyService,
    \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
    \Magento\Quote\Model\Quote\Item\Processor $itemProcessor,
    \Magento\Framework\Object\Factory $objectFactory,
    \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
    \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder,
    \Magento\Framework\Api\FilterBuilder $filterBuilder,
    \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory,
    \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory,
    \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
    \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
    \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
    \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory,
    \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
    \Magento\Framework\Model\Resource\AbstractResource $resource = null,
    \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
    \Magento\Sales\Model\Order\Config $orderConfig,
    \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory,
          \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory,
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Backend\Model\Session\Quote $quoteSession,
        \Magento\Framework\Registry $coreRegistry,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Quote\Model\Quote\Item\Updater $quoteItemUpdater,
        \Magento\Quote\Model\QuoteRepository $quoteRepository,
        array $data = []
    ) {
        parent::__construct(
            $context,
            $registry,
            $extensionFactory,
            $customAttributeFactory,
            $quoteValidator,
            $catalogProduct,
            $scopeConfig,
            $storeManager,
            $config,
            $quoteAddressFactory,
            $customerFactory,
            $groupRepository,
            $quoteItemCollectionFactory,
            $quoteItemFactory,
            $messageFactory,
            $statusListFactory,
            $productRepository,
            $quotePaymentFactory,
            $quotePaymentCollectionFactory,
            $objectCopyService,
            $stockRegistry,
            $itemProcessor,
            $objectFactory,
            $addressRepository,
            $criteriaBuilder,
            $filterBuilder,
            $addressDataFactory,
            $customerDataFactory,
            $customerRepository,
            $dataObjectHelper,
            $extensibleDataObjectConverter,
            $currencyFactory,
            $extensionAttributesJoinProcessor,
            $resource,
            $resourceCollection,
            $data
        );
        $this->_orderConfig = $orderConfig;
        $this->_quoteHistoryFactory = $quoteHistoryFactory;
        $this->_historyCollectionFactory = $historyCollectionFactory;
        $this->_objectManager = $objectManager;
        $this->_session = $quoteSession;
        $this->_coreRegistry = $coreRegistry;
        $this->messageManager = $messageManager;
        $this->quoteItemUpdater = $quoteItemUpdater;
        $this->quoteRepository = $quoteRepository;
    }

    /**
    * Init resource model
    *
    * @return void
    */
    protected function _construct()
    {
        $this->_init('Rofavadeka\AwesomeModule\Model\Resource\Quote');
    }
}
2 Added additional information on Marius hes request.
source | link

Additional information ( as requested by Marius )

My quote model:

namespace Rofavadeka\AwesomeModule\Model;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\GroupInterface;
use Magento\Framework\Model\AbstractExtensibleModel;
use Magento\Quote\Api\Data\PaymentInterface;
use Magento\Quote\Model\Quote\Address;
use Magento\Sales\Model\Resource;
use Magento\Sales\Model\Status;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;

class Quote extends \Magento\Quote\Model\Quote
{
/**
 * @var \Magento\Sales\Model\Order\Config
 */
protected $_orderConfig;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory
 */
protected $_quoteHistoryFactory;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory
 */
protected $_historyCollectionFactory;

/**
 * Re-collect quote flag
 *
 * @var boolean
 */
protected $_needCollect;

/**
 * Quote session object
 *
 * @var \Magento\Backend\Model\Session\Quote
 */
protected $_session;

/**
 * @var \Magento\Framework\ObjectManagerInterface
 */
protected $_objectManager;

/**
 * Core registry
 *
 * @var \Magento\Framework\Registry
 */
protected $_coreRegistry = null;

/**
 * @var \Magento\Framework\Message\ManagerInterface
 */
protected $messageManager;

/**
 * @var \Magento\Quote\Model\Quote\Item\Updater
 */
protected $quoteItemUpdater;

/**
 * Quote associated with the model
 *
 * @var \Rofavadeka\AwesomeModule\Model\Quote
 */
protected $_quote;

/**
 * @var \Magento\Quote\Model\QuoteRepository
 */
protected $quoteRepository;

/**
 * @param \Magento\Framework\Model\Context $context
 * @param \Magento\Framework\Registry $registry
 * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
 * @param AttributeValueFactory $customAttributeFactory
 * @param \Magento\Quote\Model\QuoteValidator $quoteValidator
 * @param \Magento\Catalog\Helper\Product $catalogProduct
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
 * @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory
 * @param \Magento\Customer\Model\CustomerFactory $customerFactory
 * @param \Magento\Customer\Api\GroupRepositoryInterface $groupRepository
 * @param \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory
 * @param \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory
 * @param \Magento\Framework\Message\Factory $messageFactory
 * @param Status\ListFactory $statusListFactory
 * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
 * @param \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory
 * @param \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory
 * @param \Magento\Framework\Object\Copy $objectCopyService
 * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
 * @param \Magento\Quote\Model\Quote\Item\Processor $itemProcessor
 * @param \Magento\Framework\Object\Factory $objectFactory
 * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
 * @param \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder
 * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
 * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory
 * @param \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory
 * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
 * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
 * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter
 * @param \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory
 * @param JoinProcessorInterface $extensionAttributesJoinProcessor
 * @param \Magento\Framework\Model\Resource\AbstractResource $resource
 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
 * @param \Magento\Sales\Model\Order\Config $orderConfig
 * @param \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory
 * @param \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory
 * @param \Magento\Framework\ObjectManagerInterface $objectManager
 * @param array $data
 *
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
 */
public function __construct(
    \Magento\Framework\Model\Context $context,
    \Magento\Framework\Registry $registry,
    \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
    AttributeValueFactory $customAttributeFactory,
    \Magento\Quote\Model\QuoteValidator $quoteValidator,
    \Magento\Catalog\Helper\Product $catalogProduct,
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Framework\App\Config\ScopeConfigInterface $config,
    \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
    \Magento\Customer\Model\CustomerFactory $customerFactory,
    \Magento\Customer\Api\GroupRepositoryInterface $groupRepository,
    \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory,
    \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory,
    \Magento\Framework\Message\Factory $messageFactory,
    \Magento\Sales\Model\Status\ListFactory $statusListFactory,
    \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
    \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory,
    \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory,
    \Magento\Framework\Object\Copy $objectCopyService,
    \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
    \Magento\Quote\Model\Quote\Item\Processor $itemProcessor,
    \Magento\Framework\Object\Factory $objectFactory,
    \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
    \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder,
    \Magento\Framework\Api\FilterBuilder $filterBuilder,
    \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory,
    \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory,
    \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
    \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
    \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
    \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory,
    \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
    \Magento\Framework\Model\Resource\AbstractResource $resource = null,
    \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
    \Magento\Sales\Model\Order\Config $orderConfig,
    \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory,
          \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory,
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Backend\Model\Session\Quote $quoteSession,
        \Magento\Framework\Registry $coreRegistry,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Quote\Model\Quote\Item\Updater $quoteItemUpdater,
        \Magento\Quote\Model\QuoteRepository $quoteRepository,
        array $data = []
    ) {
        parent::__construct(
            $context,
            $registry,
            $extensionFactory,
            $customAttributeFactory,
            $quoteValidator,
            $catalogProduct,
            $scopeConfig,
            $storeManager,
            $config,
            $quoteAddressFactory,
            $customerFactory,
            $groupRepository,
            $quoteItemCollectionFactory,
            $quoteItemFactory,
            $messageFactory,
            $statusListFactory,
            $productRepository,
            $quotePaymentFactory,
            $quotePaymentCollectionFactory,
            $objectCopyService,
            $stockRegistry,
            $itemProcessor,
            $objectFactory,
            $addressRepository,
            $criteriaBuilder,
            $filterBuilder,
            $addressDataFactory,
            $customerDataFactory,
            $customerRepository,
            $dataObjectHelper,
            $extensibleDataObjectConverter,
            $currencyFactory,
            $extensionAttributesJoinProcessor,
            $resource,
            $resourceCollection,
            $data
        );
        $this->_orderConfig = $orderConfig;
        $this->_quoteHistoryFactory = $quoteHistoryFactory;
        $this->_historyCollectionFactory = $historyCollectionFactory;
        $this->_objectManager = $objectManager;
        $this->_session = $quoteSession;
        $this->_coreRegistry = $coreRegistry;
        $this->messageManager = $messageManager;
        $this->quoteItemUpdater = $quoteItemUpdater;
        $this->quoteRepository = $quoteRepository;
    }

    /**
    * Init resource model
    *
    * @return void
    */
    protected function _construct()
    {
        $this->_init('Rofavadeka\AwesomeModule\Model\Resource\Quote');
    }
}

Additional information ( as requested by Marius )

My quote model:

namespace Rofavadeka\AwesomeModule\Model;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\GroupInterface;
use Magento\Framework\Model\AbstractExtensibleModel;
use Magento\Quote\Api\Data\PaymentInterface;
use Magento\Quote\Model\Quote\Address;
use Magento\Sales\Model\Resource;
use Magento\Sales\Model\Status;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;

class Quote extends \Magento\Quote\Model\Quote
{
/**
 * @var \Magento\Sales\Model\Order\Config
 */
protected $_orderConfig;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory
 */
protected $_quoteHistoryFactory;

/**
 * @var \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory
 */
protected $_historyCollectionFactory;

/**
 * Re-collect quote flag
 *
 * @var boolean
 */
protected $_needCollect;

/**
 * Quote session object
 *
 * @var \Magento\Backend\Model\Session\Quote
 */
protected $_session;

/**
 * @var \Magento\Framework\ObjectManagerInterface
 */
protected $_objectManager;

/**
 * Core registry
 *
 * @var \Magento\Framework\Registry
 */
protected $_coreRegistry = null;

/**
 * @var \Magento\Framework\Message\ManagerInterface
 */
protected $messageManager;

/**
 * @var \Magento\Quote\Model\Quote\Item\Updater
 */
protected $quoteItemUpdater;

/**
 * Quote associated with the model
 *
 * @var \Rofavadeka\AwesomeModule\Model\Quote
 */
protected $_quote;

/**
 * @var \Magento\Quote\Model\QuoteRepository
 */
protected $quoteRepository;

/**
 * @param \Magento\Framework\Model\Context $context
 * @param \Magento\Framework\Registry $registry
 * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
 * @param AttributeValueFactory $customAttributeFactory
 * @param \Magento\Quote\Model\QuoteValidator $quoteValidator
 * @param \Magento\Catalog\Helper\Product $catalogProduct
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
 * @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory
 * @param \Magento\Customer\Model\CustomerFactory $customerFactory
 * @param \Magento\Customer\Api\GroupRepositoryInterface $groupRepository
 * @param \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory
 * @param \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory
 * @param \Magento\Framework\Message\Factory $messageFactory
 * @param Status\ListFactory $statusListFactory
 * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
 * @param \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory
 * @param \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory
 * @param \Magento\Framework\Object\Copy $objectCopyService
 * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
 * @param \Magento\Quote\Model\Quote\Item\Processor $itemProcessor
 * @param \Magento\Framework\Object\Factory $objectFactory
 * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
 * @param \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder
 * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
 * @param \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory
 * @param \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory
 * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
 * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
 * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter
 * @param \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory
 * @param JoinProcessorInterface $extensionAttributesJoinProcessor
 * @param \Magento\Framework\Model\Resource\AbstractResource $resource
 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
 * @param \Magento\Sales\Model\Order\Config $orderConfig
 * @param \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory
 * @param \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory
 * @param \Magento\Framework\ObjectManagerInterface $objectManager
 * @param array $data
 *
 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
 */
public function __construct(
    \Magento\Framework\Model\Context $context,
    \Magento\Framework\Registry $registry,
    \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
    AttributeValueFactory $customAttributeFactory,
    \Magento\Quote\Model\QuoteValidator $quoteValidator,
    \Magento\Catalog\Helper\Product $catalogProduct,
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Framework\App\Config\ScopeConfigInterface $config,
    \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
    \Magento\Customer\Model\CustomerFactory $customerFactory,
    \Magento\Customer\Api\GroupRepositoryInterface $groupRepository,
    \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemCollectionFactory,
    \Magento\Quote\Model\Quote\ItemFactory $quoteItemFactory,
    \Magento\Framework\Message\Factory $messageFactory,
    \Magento\Sales\Model\Status\ListFactory $statusListFactory,
    \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
    \Magento\Quote\Model\Quote\PaymentFactory $quotePaymentFactory,
    \Magento\Quote\Model\Resource\Quote\Payment\CollectionFactory $quotePaymentCollectionFactory,
    \Magento\Framework\Object\Copy $objectCopyService,
    \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
    \Magento\Quote\Model\Quote\Item\Processor $itemProcessor,
    \Magento\Framework\Object\Factory $objectFactory,
    \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
    \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder,
    \Magento\Framework\Api\FilterBuilder $filterBuilder,
    \Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory,
    \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory,
    \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
    \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
    \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
    \Magento\Quote\Model\Cart\CurrencyFactory $currencyFactory,
    \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
    \Magento\Framework\Model\Resource\AbstractResource $resource = null,
    \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
    \Magento\Sales\Model\Order\Config $orderConfig,
    \Rofavadeka\AwesomeModule\Model\Quote\Status\HistoryFactory $quoteHistoryFactory,
          \Rofavadeka\AwesomeModule\Model\Resource\Quote\Status\History\CollectionFactory $historyCollectionFactory,
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Backend\Model\Session\Quote $quoteSession,
        \Magento\Framework\Registry $coreRegistry,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Quote\Model\Quote\Item\Updater $quoteItemUpdater,
        \Magento\Quote\Model\QuoteRepository $quoteRepository,
        array $data = []
    ) {
        parent::__construct(
            $context,
            $registry,
            $extensionFactory,
            $customAttributeFactory,
            $quoteValidator,
            $catalogProduct,
            $scopeConfig,
            $storeManager,
            $config,
            $quoteAddressFactory,
            $customerFactory,
            $groupRepository,
            $quoteItemCollectionFactory,
            $quoteItemFactory,
            $messageFactory,
            $statusListFactory,
            $productRepository,
            $quotePaymentFactory,
            $quotePaymentCollectionFactory,
            $objectCopyService,
            $stockRegistry,
            $itemProcessor,
            $objectFactory,
            $addressRepository,
            $criteriaBuilder,
            $filterBuilder,
            $addressDataFactory,
            $customerDataFactory,
            $customerRepository,
            $dataObjectHelper,
            $extensibleDataObjectConverter,
            $currencyFactory,
            $extensionAttributesJoinProcessor,
            $resource,
            $resourceCollection,
            $data
        );
        $this->_orderConfig = $orderConfig;
        $this->_quoteHistoryFactory = $quoteHistoryFactory;
        $this->_historyCollectionFactory = $historyCollectionFactory;
        $this->_objectManager = $objectManager;
        $this->_session = $quoteSession;
        $this->_coreRegistry = $coreRegistry;
        $this->messageManager = $messageManager;
        $this->quoteItemUpdater = $quoteItemUpdater;
        $this->quoteRepository = $quoteRepository;
    }

    /**
    * Init resource model
    *
    * @return void
    */
    protected function _construct()
    {
        $this->_init('Rofavadeka\AwesomeModule\Model\Resource\Quote');
    }
}
1
source | link