I want to do some modifications inside Subscriber.php model file inside Newsletter module with mentioned below 2 methods, so i have override model with my custom module with di.xml with following code:
<preference for="Magento\Newsletter\Model\Subscriber" type="Commercepundit\Dealerregistration\Model\Subscriber" />
Here is my Subscriber.php code:
<?php
/**
*
* @category Commercepundit
* @package Commercepundit_Dealerregistration
* @module Dealerregistration
* @author Commercepundit Developer
*/
namespace Commercepundit\Dealerregistration\Model;
/*use Commercepundit\Core\Helper\Data as CoreHelper;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;*/
class Subscriber extends \Magento\Newsletter\Model\Subscriber
{
public function __construct(
\Commercepundit\Core\Helper\Data $coreHelper
)
{
$this->coreHelper = $coreHelper;
}
/**
* Sends out confirmation email
*
* @return $this
*/
public function sendConfirmationRequestEmail()
{
if ($this->getImportMode()) {
return $this;
}
if (!$this->_scopeConfig->getValue(
self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
) || !$this->_scopeConfig->getValue(
self::XML_PATH_CONFIRM_EMAIL_IDENTITY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
) {
return $this;
}
$this->inlineTranslation->suspend();
$this->_transportBuilder->setTemplateIdentifier(
$this->_scopeConfig->getValue(
self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
)->setTemplateOptions(
[
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'store' => $this->_storeManager->getStore()->getId(),
]
)->setTemplateVars(
['subscriber' => $this, 'store' => $this->_storeManager->getStore()]
)->setFrom(
$this->_scopeConfig->getValue(
self::XML_PATH_CONFIRM_EMAIL_IDENTITY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
)->addTo(
$this->getEmail(),
$this->getName()
);
$transport = $this->_transportBuilder->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
return $this;
}
/**
* Sends out confirmation success email
*
* @return $this
*/
public function sendConfirmationSuccessEmail()
{
$storeId = $this->getStoreId();
if ($this->getImportMode()) {
return $this;
}
if (!$this->_scopeConfig->getValue(
self::XML_PATH_SUCCESS_EMAIL_TEMPLATE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
) || !$this->_scopeConfig->getValue(
self::XML_PATH_SUCCESS_EMAIL_IDENTITY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
) {
return $this;
}
$this->inlineTranslation->suspend();
$this->_transportBuilder->setTemplateIdentifier(
$this->_scopeConfig->getValue(
self::XML_PATH_SUCCESS_EMAIL_TEMPLATE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
)->setTemplateOptions(
[
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'store' => $this->_storeManager->getStore()->getId(),
]
)->setTemplateVars(
['subscriber' => $this]
)->setFrom(
$this->_scopeConfig->getValue(
self::XML_PATH_SUCCESS_EMAIL_IDENTITY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
)->addTo(
$this->getEmail(),
$this->getName()
);
$transport = $this->_transportBuilder->getTransport();
$transport->sendMessage();
$this->inlineTranslation->resume();
return $this;
}
}
When i run this code, i am getting following error: There was a problem with the subscription: The resource isn't set.
Can anyone let me know what could be missing?