[英]Magento - $_orders = Mage::getResourceModel outputs the SQL string - Recent.php
I'm trying to output more orders on the front end of /customer/account Recent Orders grid. 我试图在/ customer / account最近的订单网格的前端输出更多的订单。
The code in /Mage/Sales/Order/Block/Recent.php says this /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();
?>
When I edit number ->load(10) it outputs a string of the query that was created. 当我编辑number-> load(10)时,它输出所创建查询的字符串。 There is no echo anywhere in Recent.php 在Latest.php中的任何地方都没有回声
It also does not add 10 Orders, just stays at default 5. What am I missing? 它也不会添加10个订单,只是保持默认值5。我缺少什么?
I tried putting this straight into recent.phtml 我尝试将其直接放入最近.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');
?>
And it changes the number of orders to 10, but still outputs the SQL query. 并将订单数更改为10,但仍输出SQL查询。
Query 询问
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
Any ideas? 有任何想法吗?
try 尝试
<?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);
?>
added: 0 inside of the ->load() 补充:-> load()内部为0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.