_coreRegistry = $registry; $this->customerRepository = $customerRepository; $this->_productFactory = $productFactory; $this->_customerViewHelper = $customerViewHelper; parent::__construct($context, $data); } /** * Initialize add new review * * @return void */ protected function _construct() { $this->_addButtonLabel = __('New Review'); parent::_construct(); $this->_blockGroup = 'Magento_Review'; $this->_controller = 'adminhtml'; // lookup customer, if id is specified $customerId = $this->getRequest()->getParam('customerId', false); $customerName = ''; if ($customerId) { $customer = $this->customerRepository->getById($customerId); $customerName = $this->escapeHtml($this->_customerViewHelper->getCustomerName($customer)); } $productId = $this->getRequest()->getParam('productId', false); $productName = null; if ($productId) { $product = $this->_productFactory->create()->load($productId); $productName = $this->escapeHtml($product->getName()); } if ($this->_coreRegistry->registry('usePendingFilter') === true) { if ($customerName) { $this->_headerText = __('Pending Reviews of Customer `%1`', $customerName); } else { $this->_headerText = __('Pending Reviews'); } $this->buttonList->remove('add'); } else { if ($customerName) { $this->_headerText = __('All Reviews of Customer `%1`', $customerName); } elseif ($productName) { $this->_headerText = __('All Reviews of Product `%1`', $productName); } else { $this->_headerText = __('All Reviews'); } } } }