-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Area: FrontendIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for development
Description
Preconditions
Magento 2.1.6 and earlier
PHP version is irrelevant
Steps to reproduce
Place enough orders to surpass the lower page limit for customer orders.
In other words, you need a customer account with at least 11 orders.
Log into the account and view the order list.
Expected result
The orders should be paged based on the pager limit
Actual result
All orders are shown and the pager displays [total order number]/[page limit] orders
After digging into the issue, this problem is due to an oversight in the Magento\Sales\Block\Order\History class in the getOrders function.
/**
* @return bool|\Magento\Sales\Model\ResourceModel\Order\Collection
*/
public function getOrders()
{
if (!($customerId = $this->_customerSession->getCustomerId())) {
return false;
}
if (!$this->orders) {
$this->orders = $this->getOrderCollectionFactory()->create($customerId)->addFieldToSelect(
'*'
)->addFieldToFilter(
'status',
['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
)->setOrder(
'created_at',
'desc'
);
}
return $this->orders;
}
This should include setting the current page based on the default or current params.
/**
* @return bool|\Magento\Sales\Model\ResourceModel\Order\Collection
*/
public function getOrders()
{
if (!($customerId = $this->_customerSession->getCustomerId())) {
return false;
}
if (!$this->orders) {
$this->orders = $this->getOrderCollectionFactory()->create($customerId)->addFieldToSelect(
'*'
)->addFieldToFilter(
'status',
['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
)->setOrder(
'created_at',
'desc'
);
}
$page = $this->getRequest()->getParam('p') ?: 1;
$num = $this->getRequest()->getParam('limit') ?: 10;
$this->orders->setPage($page, $num);
return $this->orders;
}
Metadata
Metadata
Assignees
Labels
Area: FrontendIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentGate 4. Acknowledged. Issue is added to backlog and ready for development