abandonedCollectionFactory = $abandoned; $this->dateTime = $dateTime; parent::__construct( $context, $registry, $resource, $resourceCollection, $data ); } /** * Constructor. * * @return null */ public function _construct() { parent::_construct(); $this->_init(\Dotdigitalgroup\Email\Model\ResourceModel\Abandoned::class); } /** * Prepare data to be saved to database. * * @return $this */ public function beforeSave() { parent::beforeSave(); if ($this->isObjectNew()) { $this->setCreatedAt($this->dateTime->formatDate(true)); } $this->setUpdatedAt($this->dateTime->formatDate(true)); return $this; } /** * @param int $quoteId * @return \Dotdigitalgroup\Email\Model\Abandoned */ public function loadByQuoteId($quoteId) { $collection = $this->abandonedCollectionFactory->create() ->addFieldToFilter('quote_id', $quoteId) ->setPageSize(1); return $collection->getFirstItem(); } }