2015-10-02 22 views
1

我試圖在/ customer/account最近訂單網格的前端輸出更多訂單。 >負載(10),它輸出所創建的查詢的一個字符串 -

當我編輯數/Mage/Sales/Order/Block/Recent.php的代碼表示,這

<?php $_orders = Mage::getResourceModel('sales/order_collection') 
     ->addAttributeToSelect('*')    
     ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left') 
     ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left') 
     ->addAttributeToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()) 
     ->addAttributeToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) 
     ->addAttributeToSort('created_at', 'desc') 
     ->setPageSize(5)   
     ->load(); 
?> 

。 Recent.php中沒有任何回聲

它也不會添加10個訂單,只是保持默認值5.我錯過了什麼?

我試圖把這個直接進入recent.phtml

<?php $_orders = Mage::getResourceModel('sales/order_collection') 
     ->addAttributeToSelect('*')    
     ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left') 
     ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left') 
     ->addAttributeToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()) 
     ->addAttributeToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) 
     ->addAttributeToSort('created_at', 'desc') 
     ->setPageSize('10')   
     ->load('10'); 
?> 

它改變的訂單數量爲10,但仍輸出的SQL查詢。

查詢

SELECT `main_table`.* FROM `sales_flat_order` AS `main_table` WHERE (main_table.customer_id = '1') AND (state IN('new', 'processing', 'complete', 'closed', 'canceled', 'holded', 'payment_review')) ORDER BY created_at DESC LIMIT 10 10 

任何想法?

+2

第一,你不應該修改的核心文件。如果你想修改覆蓋。並嘗試'加載()'和'setPageSize(10)'更多的訂單 – urfusion

+0

這是工作。謝謝!我如何將您的評論發佈爲答案? PS:只是試圖讓代碼在開發機器上工作,在原型工作後移動到本地。 –

+0

歡迎,現在你可以接受。 :) – urfusion

回答

1

嘗試

<?php $_orders = Mage::getResourceModel('sales/order_collection') 
     ->addAttributeToSelect('*')    
     ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left') 
     ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left') 
     ->addAttributeToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()) 
     ->addAttributeToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) 
     ->addAttributeToSort('created_at', 'desc') 
     ->setPageSize('10')   
     ->load(0); 
?> 

補充道:0的內部 - >負載()