magento2-plugin/Model/ResourceModel/Invoice/Grid/Collection.php
2021-09-01 11:14:17 +02:00

54 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* Integrates BTCPay Server with Magento 2 for online payments
* @copyright Copyright © 2019-2021 Storefront bv. All rights reserved.
* @author Wouter Samaey - wouter.samaey@storefront.be
*
* This file is part of Storefront/BTCPay.
*
* Storefront/BTCPay is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Storefront\BTCPay\Model\ResourceModel\Invoice\Grid;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;
class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult {
public function __construct(EntityFactory $entityFactory, Logger $logger, FetchStrategy $fetchStrategy, EventManager $eventManager, $identifierName = null, $connectionName = null) {
$mainTable = 'btcpay_invoices';
$resourceModel = \Storefront\BTCPay\Model\ResourceModel\Invoice\Collection::class;
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel, $identifierName, $connectionName);
}
public function _initSelect() {
$r = parent::_initSelect();
$this->getSelect()->joinLeft(['order' => $this->getTable('sales_order')], 'main_table.order_id = order.entity_id', [
'order_increment_id' => 'increment_id'
]);
$this->addFilterToMap('order_increment_id', 'order.increment_id');
return $r;
}
}