storeManager = $context->getStoreManager();
$this->rssModel = $rssModel;
$this->httpContext = $httpContext;
$this->rssUrlBuilder = $rssUrlBuilder;
parent::__construct($context, $data);
}
/**
* {@inheritdoc}
*/
protected function _construct()
{
$this->setCacheKey('rss_catalog_salesrule_' . $this->getStoreId() . '_' . $this->getCustomerGroupId());
parent::_construct();
}
/**
* {@inheritdoc}
*/
public function getRssData()
{
$storeId = $this->getStoreId();
$storeModel = $this->storeManager->getStore($storeId);
$websiteId = $storeModel->getWebsiteId();
$customerGroupId = $this->getCustomerGroupId();
$url = $this->_urlBuilder->getUrl('');
$newUrl = $this->rssUrlBuilder->getUrl([
'type' => 'discounts',
'store_id' => $storeId,
'cid' => $customerGroupId,
]);
$title = __('%1 - Discounts and Coupons', $storeModel->getFrontendName());
$lang = $this->_scopeConfig->getValue(
'general/locale/code',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeModel
);
$data = [
'title' => $title,
'description' => $title,
'link' => $newUrl,
'charset' => 'UTF-8',
'language' => $lang,
];
/** @var $rule \Magento\SalesRule\Model\Rule */
foreach ($this->rssModel->getDiscountCollection($websiteId, $customerGroupId) as $rule) {
$toDate = $rule->getToDate()
? '
Discount End Date: ' . $this->formatDate($rule->getToDate(), \IntlDateFormatter::MEDIUM)
: '';
$couponCode = $rule->getCouponCode() ? '
Coupon Code: ' . $rule->getCouponCode() : '';
$description = sprintf(
'
%s Discount Start Date: %s %s %s |