Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Rss.php
Go to the documentation of this file.
1 <?php
7 
9 
15 {
19  protected $storeManager;
20 
24  protected $rssModel;
25 
32  public function __construct(
33  \Magento\Backend\Block\Context $context,
35  \Magento\Review\Model\Rss $rssModel,
36  array $data = []
37  ) {
38  $this->storeManager = $storeManager;
39  $this->rssModel = $rssModel;
40  parent::__construct($context, $data);
41  }
42 
46  public function getRssData()
47  {
48  $newUrl = $this->getUrl('rss/catalog/review', ['_secure' => true, '_nosecret' => true]);
49  $title = __('Pending product review(s)');
50 
51  $data = ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'];
52 
53  foreach ($this->rssModel->getProductCollection() as $item) {
54  if ($item->getStoreId()) {
55  $this->_urlBuilder->setScope($item->getStoreId());
56  }
57 
58  $url = $this->getUrl('catalog/product/view', ['id' => $item->getId()]);
59  $reviewUrl = $this->getUrl('review/product/edit/', [
60  'id' => $item->getReviewId(),
61  '_secure' => true,
62  '_nosecret' => true
63  ]);
64 
65  $storeName = $this->storeManager->getStore($item->getStoreId())->getName();
66  $description = '<p>' . __('Product: <a href="%1" target="_blank">%2</a> <br/>', $url, $item->getName())
67  . __('Summary of review: %1 <br/>', $item->getTitle()) . __('Review: %1 <br/>', $item->getDetail())
68  . __('Store: %1 <br/>', $storeName)
69  . __('Click <a href="%1">here</a> to see the review.', $reviewUrl)
70  . '</p>';
71 
72  $data['entries'][] = [
73  'title' => __('Product: "%1" reviewed by: %2', $item->getName(), $item->getNickname()),
74  'link' => $item->getProductUrl(),
75  'description' => $description,
76  ];
77  }
78 
79  return $data;
80  }
81 
85  public function getCacheLifetime()
86  {
87  return 0;
88  }
89 
93  public function isAllowed()
94  {
95  return true;
96  }
97 
101  public function getFeeds()
102  {
103  return [];
104  }
105 
109  public function isAuthRequired()
110  {
111  return true;
112  }
113 }
$title
Definition: default.phtml:14
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Review\Model\Rss $rssModel, array $data=[])
Definition: Rss.php:32
$storeName
Definition: logo.phtml:13