47 lines
1.5 KiB
PHP
Executable File
47 lines
1.5 KiB
PHP
Executable File
<?php
|
|
namespace IpSupply\CartToQuote\Block\Customer\History;
|
|
|
|
class Quote extends \Magento\Framework\View\Element\Template
|
|
{
|
|
protected $carttHistoryFactory;
|
|
public function __construct(
|
|
\Magento\Backend\Block\Template\Context $context,
|
|
\IpSupply\CartToQuote\Model\CartHistoryFactory $carttHistoryFactory,
|
|
array $data = []
|
|
)
|
|
{
|
|
$this->carttHistoryFactory = $carttHistoryFactory;
|
|
parent::__construct($context, $data);
|
|
}
|
|
|
|
public function getCarttHistories($customerId)
|
|
{
|
|
$current_page = (int) $this->getRequest()->getParam('current_page');
|
|
if ($current_page == 0) {
|
|
$current_page = 1;
|
|
}
|
|
$size = (int) $this->getRequest()->getParam('size');
|
|
if ($size == 0) {
|
|
$size = 20;
|
|
}
|
|
$collection = $this->carttHistoryFactory->create()->getCollection();
|
|
$data = $collection->addFieldToFilter('customer_id', ['eq' => $customerId])
|
|
->setOrder('date','DESC')
|
|
->setPageSize($size)
|
|
->setCurPage($current_page)
|
|
->getData();
|
|
$collection = $this->carttHistoryFactory->create()->getCollection();
|
|
$total = $collection->addFieldToFilter('customer_id', ['eq' => $customerId])
|
|
->count();
|
|
$result = array(
|
|
"data" => $data,
|
|
"total" => $total,
|
|
"current_page" => $current_page,
|
|
"size" => $size
|
|
);
|
|
return $result;
|
|
}
|
|
|
|
}
|
|
?>
|