示例#1
0
 /**
  * Retrieve tags
  * @return array
  */
 public function getTags()
 {
     if ($this->_tags === null) {
         $this->_tags = $this->_tagCollectionFactory->create();
         $resource = $this->_tags->getResource();
         $this->_tags->getSelect()->joinLeft(['pt' => $resource->getTable('magefan_blog_post_tag')], 'main_table.tag_id = pt.tag_id', [])->joinLeft(['p' => $resource->getTable('magefan_blog_post')], 'p.post_id = pt.post_id', [])->joinLeft(['ps' => $resource->getTable('magefan_blog_post_store')], 'p.post_id = pt.post_id', ['count' => 'count(main_table.tag_id)'])->group('main_table.tag_id')->where('ps.store_id IN (?)', [0, (int) $this->_storeManager->getStore()->getId()]);
     }
     return $this->_tags;
 }
示例#2
0
 /**
  * Get data
  *
  * @return array
  */
 public function getData()
 {
     if (isset($this->loadedData)) {
         return $this->loadedData;
     }
     $items = $this->collection->getItems();
     /** @var $tag \Magefan\Blog\Model\Tag */
     foreach ($items as $tag) {
         $this->loadedData[$tag->getId()] = $tag->getData();
     }
     $data = $this->dataPersistor->get('current_model');
     if (!empty($data)) {
         $tag = $this->collection->getNewEmptyItem();
         $tag->setData($data);
         $this->loadedData[$tag->getId()] = $tag->getData();
         $this->dataPersistor->clear('current_model');
     }
     return $this->loadedData;
 }