I running the following code
class MyOrders extends AbstractCollection implements MyOrdersInterface{
public function _construct(){
$this->_init('\Magento\Sales\Model\Order', 'Magento\Sales\Model\ResourceModel\Order');
}
/**
* @api
* @param int $customerId
* @return array
*/
public function getOrders($customerId){
//if (!$this->orders) {
$orders = $this->create()->addFieldToSelect(
'*'
)->addFieldToFilter(
'customer_id',
$customerId
)->setOrder(
'created_at',
'desc'
);
//}
//$ordersCollection = $this->addAttributeToFilter("customer_id", $customerId)->load();
$a=array($orders);
return $a;
}
}
but xampp error log gives me the following error
PHP Fatal error: Allowed memory size of 792723456 bytes exhausted (tried to
allocate 387989504 bytes) in C:\\xampp\\htdocs\\yourParts\\app\\code\\Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection.php on line 246
I've changed memory_limit = -1 in php.ini but it doesn't work
MyOrdersInterface
? You should try using the Order collection factory like this: magento.stackexchange.com/a/110483/2671 – DanCarlyon Nov 18 '18 at 11:44