![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-reports/Block/Adminhtml/Product/Viewed/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Reports\Block\Adminhtml\Product\Viewed; /** * Adminhtml most viewed products report grid block * * @author Magento Core Team <[email protected]> * @SuppressWarnings(PHPMD.DepthOfInheritance) */ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** * Column for grid to be grouped by * * @var string */ protected $_columnGroupBy = 'period'; /** * Grid resource collection name * * @var string */ protected $_resourceCollectionName = \Magento\Reports\Model\ResourceModel\Report\Product\Viewed\Collection::class; /** * Init grid parameters * * @return void */ protected function _construct() { parent::_construct(); $this->setCountTotals(true); } /** * Custom columns preparation * * @return \Magento\Backend\Block\Widget\Grid\Extended */ protected function _prepareColumns() { $this->addColumn( 'period', [ 'header' => __('Interval'), 'index' => 'period', 'width' => 100, 'sortable' => false, 'period_type' => $this->getPeriodType(), 'renderer' => \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::class, 'totals_label' => __('Total'), 'html_decorators' => ['nobr'], 'header_css_class' => 'col-period', 'column_css_class' => 'col-period' ] ); $this->addColumn( 'product_name', [ 'header' => __('Product'), 'index' => 'product_name', 'type' => 'string', 'sortable' => false, 'header_css_class' => 'col-name', 'column_css_class' => 'col-name' ] ); if ($this->getFilterData()->getStoreIds()) { $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds())); } $currencyCode = $this->getCurrentCurrencyCode(); $this->addColumn( 'product_price', [ 'header' => __('Price'), 'type' => 'currency', 'currency_code' => $currencyCode, 'index' => 'product_price', 'sortable' => false, 'rate' => $this->getRate($currencyCode), 'header_css_class' => 'col-price', 'column_css_class' => 'col-price' ] ); $this->addColumn( 'views_num', [ 'header' => __('Views'), 'index' => 'views_num', 'type' => 'number', 'total' => 'sum', 'sortable' => false, 'header_css_class' => 'col-qty', 'column_css_class' => 'col-qty' ] ); $this->addExportType('*/*/exportViewedCsv', __('CSV')); $this->addExportType('*/*/exportViewedExcel', __('Excel XML')); return parent::_prepareColumns(); } /** * Don't use orders in collection * * @param \Magento\Reports\Model\ResourceModel\Report\Collection\AbstractCollection $collection * @param \Magento\Framework\DataObject $filterData * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function _addOrderStatusFilter($collection, $filterData) { return $this; } }