php获取产品订单列表,php – magento订单列表查询

这段代码演示了如何在Magento环境中通过Model层访问和处理销售订单数据。它展示了如何加入各种地址属性,过滤订单状态,并按创建时间排序。代码加载了订单集合,按特定条件筛选(如完成或关闭状态,指定商店ID),并打印出订单ID和电话号码。
摘要由CSDN通过智能技术生成

此代码使用“Magento方式”并通过Model层访问数据,这使您可以隔离表结构的变化(例如,平坦与EAV).在Magento安装的根目录中创建一个包含此框架代码的新PHP文件(如果在其他位置更新第一个require语句的路径).

这给出了一些如何向集合添加属性的示例,您应该能够按照示例添加更多(如果需要).它向您展示了如何按属性过滤,并按属性排序.回声您需要的字段的示例.

HTH,

JD

require_once 'app/Mage.php';

umask(0);

Mage::app('default');

$orders = Mage::getResourceModel('sales/order_collection')

->addAttributeToSelect('*')

->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')

->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')

->joinAttribute('billing_street', 'order_address/street', 'billing_address_id', null, 'left')

->joinAttribute('billing_company', 'order_address/company', 'billing_address_id', null, 'left')

->joinAttribute('billing_city', 'order_address/city', 'billing_address_id', null, 'left')

->joinAttribute('billing_region', 'order_address/region', 'billing_address_id', null, 'left')

->joinAttribute('billing_country', 'order_address/country_id', 'billing_address_id', null, 'left')

->joinAttribute('billing_postcode', 'order_address/postcode', 'billing_address_id', null, 'left')

->joinAttribute('billing_telephone', 'order_address/telephone', 'billing_address_id', null, 'left')

->joinAttribute('billing_fax', 'order_address/fax', 'billing_address_id', null, 'left')

->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_street', 'order_address/street', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_company', 'order_address/company', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_city', 'order_address/city', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_region', 'order_address/region', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_country', 'order_address/country_id', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_postcode', 'order_address/postcode', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_telephone', 'order_address/telephone', 'shipping_address_id', null, 'left')

->joinAttribute('shipping_fax', 'order_address/fax', 'shipping_address_id', null, 'left')

->addFieldToFilter('status', array("in" => array(

'complete',

'closed')

))

->addAttributeToFilter('store_id', Mage::app()->getStore()->getId())

->addAttributeToSort('created_at', 'asc')

->load();

foreach($orders as $order):

echo $order->getIncrementId().'
';

echo $order->getShippingTelephone().'
';

endforeach;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值