Beispiel #1
0
 /**
  * prepare collection
  * @return $this
  */
 protected function _prepareCollection()
 {
     $collection = $this->authorCollectionFactory->create();
     if ($this->getProduct()->getId()) {
         $constraint = 'related.product_id=' . $this->getProduct()->getId();
     } else {
         $constraint = 'related.product_id=0';
     }
     $collection->getSelect()->joinLeft(['related' => $collection->getTable('sample_news_author_product')], 'related.author_id = main_table.author_id AND ' . $constraint, ['position']);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Beispiel #2
0
 /**
  * @return array
  */
 public function getRssData()
 {
     $url = $this->urlModel->getListUrl();
     $data = ['title' => __('Authors'), 'description' => __('Authors'), 'link' => $url, 'charset' => 'UTF-8'];
     $collection = $this->authorCollectionFactory->create();
     $collection->addStoreFilter($this->getStoreId());
     $collection->addFieldToFilter('is_active', 1);
     //TODO: use constant
     $collection->addFieldToFilter('in_rss', 1);
     //TODO: use constant
     foreach ($collection as $item) {
         /** @var \Sample\News\Model\Author $item */
         //TODO: add more attributes to RSS
         $description = '<table><tr><td><a href="%s">%s</a></td></tr></table>';
         $description = sprintf($description, $item->getAuthorUrl(), $item->getName());
         $data['entries'][] = ['title' => $item->getName(), 'link' => $item->getAuthorUrl(), 'description' => $description];
     }
     return $data;
 }