magento 2 /内存不足错误

时间:2018-01-26 08:46:30

标签: php magento magento2

我正在尝试获取订单但收到错误:

  

PHP致命错误:内存不足(分配887095296)(试过   分配803225600字节)

我有2GB的 memory_limit 。我在调用订单功能时遇到错误。这是我获取订单的代码:

<?php
namespace Vendor\ExtName\Block;

class Add extends \Magento\Framework\View\Element\Template
{
    protected $_orderCollectionFactory;
    protected $_orderConfig;

    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
        \Magento\Sales\Model\Order\Config $orderConfig,
        array $data = []
    ) {
        $this->_orderCollectionFactory = $orderCollectionFactory;
        $this->_orderConfig = $orderConfig;
        parent::__construct($context, $data);
    }
    public function orders($customerId) {
        $orders = $this->_orderCollectionFactory->create()->addFieldToSelect(
            '*'
        )->addFieldToFilter(
            'customer_id',
            $customerId
        )->addFieldToFilter(
            'status',
            ['in' => 'pending']
        )->setOrder(
            'created_at',
            'desc'
        )->setPageSize(
            '5'
        )->load();

        return $orders;
    }
}

0 个答案:

没有答案