I am currently showing all my orders in My Account dashboard. The problem only 5 orders are shown when I fetch all orders.

$_orders = $block->getOrders();

but I have 29 orders in the database, it only shows 5 orders. How to get all the orders.

I have UI like this

enter image description here

When I fetch all order for dashboard section in recent.phtml /Magento/Sales/orders/recent.phtml i only get 5 orders

whereas /Magento/Sales/orders/history.phtml i get all orders

I tried this

class Recent extends  \Magento\Sales\Block\Order\Recent

 * Limit of orders
const YX_ORDER_LIMIT = 5000;

 * @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
protected $_orderCollectionFactory;

 * @var \Magento\Customer\Model\Session
protected $_customerSession;

 * @var \Magento\Sales\Model\Order\Config
protected $_orderConfig;

 * @var \Magento\Store\Model\StoreManagerInterface
private $storeManager;

protected function _construct()

private function getRecentOrders()

    $this->storeManager = ObjectManager::getInstance()

    $orders = $this->_orderCollectionFactory->create()->addAttributeToSelect(
        ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
        self:: YX_ORDER_LIMIT


It didnt work

  • Do you have all 29 orders with the same customer which you have logged in ? – Mohit chauhan Mar 4 '19 at 14:02
  • @Mohitchauhan Yes – summu Mar 5 '19 at 7:23

The method getOrders() has a filter on order status and shows only the orders with status visible_on_front = 1 (the field is in table sales_order_status_state). That excludes for example the status pending_payment.

So you can either set visible_on_front = 1 for every status ore overwrite the block and change the getOrder() method.

For the recent orders there is a hard limit of 5 in the constructor. You should create a own block extending Magento\Sales\Block\Order\Recent, implement there the getOrders() method (copy it from History block) and change the default Magento Block in the layout with your block.

| improve this answer | |
  • All orders visible, I have orders tab also in my account, for orders tab it fetches all orders but for dashboard section , it only fetches 5 orders – summu Mar 4 '19 at 14:05
  • see my updated question – summu Mar 4 '19 at 14:11
  • ok, I have updated my answer - see the hard limit of 5 in Recent block – HelgeB Mar 4 '19 at 14:13
  • getOrders() function is only in Magento\Sales\Block\Order\History as i checked, not in Magento\Sales\Block\Order\Recent – summu Mar 4 '19 at 14:22
  • Magento has implicit setter/getter if there is no explicit method. For testing, just try to copy the method from History block into Recent block, delete everything except parent::_construct(); from the _construct() method in Recent block and you will see all the orders will come :-) – HelgeB Mar 4 '19 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.