init
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LegacyOrder\Controller\Account;
|
||||
|
||||
use Magento\Customer\Controller\AbstractAccount;
|
||||
use Magento\Customer\Model\Session;
|
||||
use Magento\Framework\App\Action\Context;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class View extends AbstractAccount implements HttpGetActionInterface
|
||||
{
|
||||
public function __construct(
|
||||
Context $context,
|
||||
private readonly PageFactory $pageFactory,
|
||||
private readonly Session $customerSession,
|
||||
private readonly ResourceConnection $resource
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$legacyOrderId = (int)$this->getRequest()->getParam('id');
|
||||
$customerId = (int)$this->customerSession->getCustomerId();
|
||||
$connection = $this->resource->getConnection();
|
||||
$exists = $connection->fetchOne(
|
||||
$connection->select()
|
||||
->from($this->resource->getTableName('esun_legacy_order'), ['legacy_order_id'])
|
||||
->where('legacy_order_id = ?', $legacyOrderId)
|
||||
->where('customer_id = ?', $customerId)
|
||||
);
|
||||
|
||||
if (!$exists) {
|
||||
$this->messageManager->addErrorMessage(__('The historical order could not be found.'));
|
||||
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)
|
||||
->setPath('legacy_order/account/index');
|
||||
}
|
||||
|
||||
$page = $this->pageFactory->create();
|
||||
$page->getConfig()->getTitle()->set(__('Historical Order'));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user