Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function prepareDataSource(array $dataSource)
 {
     $dataSource = parent::prepareDataSource($dataSource);
     $options = $this->source->getReviewStatuses();
     if (empty($dataSource['data']['items'])) {
         return $dataSource;
     }
     foreach ($dataSource['data']['items'] as &$item) {
         if (isset($options[$item['status_id']])) {
             $item['status_id'] = $options[$item['status_id']];
         }
     }
     return $dataSource;
 }
Esempio n. 2
0
 /**
  * Prepare grid columns
  *
  * @return \Magento\Backend\Block\Widget\Grid
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareColumns()
 {
     $this->addColumn('review_id', ['header' => __('ID'), 'filter_index' => 'rt.review_id', 'index' => 'review_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
     $this->addColumn('created_at', ['header' => __('Created'), 'type' => 'datetime', 'filter_index' => 'rt.created_at', 'index' => 'review_created_at', 'header_css_class' => 'col-date', 'column_css_class' => 'col-date']);
     if (!$this->_coreRegistry->registry('usePendingFilter')) {
         $this->addColumn('status', ['header' => __('Status'), 'type' => 'options', 'options' => $this->_reviewData->getReviewStatuses(), 'filter_index' => 'rt.status_id', 'index' => 'status_id']);
     }
     $this->addColumn('title', ['header' => __('Title'), 'filter_index' => 'rdt.title', 'index' => 'title', 'type' => 'text', 'truncate' => 50, 'escape' => true]);
     $this->addColumn('nickname', ['header' => __('Nickname'), 'filter_index' => 'rdt.nickname', 'index' => 'nickname', 'type' => 'text', 'truncate' => 50, 'escape' => true, 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
     $this->addColumn('detail', ['header' => __('Review'), 'index' => 'detail', 'filter_index' => 'rdt.detail', 'type' => 'text', 'truncate' => 50, 'nl2br' => true, 'escape' => true]);
     /**
      * Check is single store mode
      */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $this->addColumn('visible_in', ['header' => __('Visibility'), 'index' => 'stores', 'type' => 'store', 'store_view' => true]);
     }
     $this->addColumn('type', ['header' => __('Type'), 'type' => 'select', 'index' => 'type', 'filter' => 'Magento\\Review\\Block\\Adminhtml\\Grid\\Filter\\Type', 'renderer' => 'Magento\\Review\\Block\\Adminhtml\\Grid\\Renderer\\Type']);
     $this->addColumn('name', ['header' => __('Product'), 'type' => 'text', 'index' => 'name', 'escape' => true]);
     $this->addColumn('sku', ['header' => __('SKU'), 'type' => 'text', 'index' => 'sku', 'escape' => true]);
     $this->addColumn('action', ['header' => __('Action'), 'type' => 'action', 'getter' => 'getReviewId', 'actions' => [['caption' => __('Edit'), 'url' => ['base' => 'review/product/edit', 'params' => ['productId' => $this->getProductId(), 'customerId' => $this->getCustomerId(), 'ret' => $this->_coreRegistry->registry('usePendingFilter') ? 'pending' : null]], 'field' => 'id']], 'filter' => false, 'sortable' => false]);
     $block = $this->getLayout()->getBlock('grid.bottom.links');
     if ($block) {
         $this->setChild('grid.bottom.links', $block);
     }
     return parent::_prepareColumns();
 }
Esempio n. 3
0
 /**
  * Add status filter
  *
  * @param int|string $status
  * @return $this
  */
 public function addStatusFilter($status)
 {
     if (is_string($status)) {
         $statuses = array_flip($this->_reviewData->getReviewStatuses());
         $status = isset($statuses[$status]) ? $statuses[$status] : 0;
     }
     if (is_numeric($status)) {
         $this->addFilter('status', $this->getConnection()->quoteInto('main_table.status_id=?', $status), 'string');
     }
     return $this;
 }