67 lines
2.4 KiB
PHP
67 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
|
|
namespace Stemcell\Checkout\Block\Cart;
|
|
|
|
use Magento\Customer\Model\Session;
|
|
use Magento\Framework\Data\CollectionFactory;
|
|
use Stemcell\Customer\Model\ResourceModel;
|
|
use Stemcell\Customer\Model\Salesperson;
|
|
|
|
class Grid extends \Magento\Checkout\Block\Cart\Grid
|
|
{
|
|
protected ResourceModel\Salesperson\Collection $salespersonCollection;
|
|
protected CollectionFactory $baseCollectionFactory;
|
|
|
|
public function __construct(
|
|
\Magento\Framework\View\Element\Template\Context $context,
|
|
\Magento\Customer\Model\Session $customerSession,
|
|
\Magento\Checkout\Model\Session $checkoutSession,
|
|
\Magento\Catalog\Model\ResourceModel\Url $catalogUrlBuilder,
|
|
\Magento\Checkout\Helper\Cart $cartHelper,
|
|
\Magento\Framework\App\Http\Context $httpContext,
|
|
\Magento\Quote\Model\ResourceModel\Quote\Item\CollectionFactory $itemCollectionFactory,
|
|
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor,
|
|
ResourceModel\Salesperson\Collection $salespersonCollection,
|
|
CollectionFactory $baseCollectionFactory,
|
|
array $data = []
|
|
) {
|
|
parent::__construct(
|
|
$context,
|
|
$customerSession,
|
|
$checkoutSession,
|
|
$catalogUrlBuilder,
|
|
$cartHelper,
|
|
$httpContext,
|
|
$itemCollectionFactory,
|
|
$joinProcessor,
|
|
$data
|
|
);
|
|
|
|
$this->baseCollectionFactory = $baseCollectionFactory;
|
|
$this->salespersonCollection = $salespersonCollection;
|
|
}
|
|
|
|
public function getSalesperson(): \Magento\Framework\Data\Collection|ResourceModel\Salesperson\Collection
|
|
{
|
|
if ($this->_customerSession->getCustomerId()) {
|
|
$this->salespersonCollection->getSelect()->joinInner(
|
|
'customer_salesperson',
|
|
'customer_salesperson.salesperson_id = main_table.salesperson_id and
|
|
customer_salesperson.customer_id = '.$this->_customerSession->getCustomerId(),
|
|
);
|
|
|
|
return $this->salespersonCollection;
|
|
}
|
|
|
|
return $this->baseCollectionFactory->create()->setItemObjectClass(Salesperson::class);
|
|
}
|
|
|
|
public function getQuoteData($key) {
|
|
return $this->getQuote()? $this->getQuote()->getData($key):null;
|
|
}
|
|
}
|