/** * Initialize review form * * @return void */ protected function _construct() { parent::_construct(); $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite()); if (!$this->getAllowWriteReviewFlag()) { $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form'); $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam])); } $this->setTemplate('form.phtml'); }
/** * Initialize review form * * @return void */ protected function _construct() { parent::_construct(); $data = $this->_reviewSession->getFormData(true); $data = new \Magento\Framework\Object((array) $data); // add logged in customer name as nickname if (!$data->getNickname()) { $customer = $this->_customerSession->getCustomerDataObject(); if ($customer && $customer->getId()) { $data->setNickname($customer->getFirstname()); } } $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite()); if (!$this->getAllowWriteReviewFlag()) { $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form'); $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam])); } $this->setTemplate('form.phtml')->assign('data', $data); }