以下代码为我提供了“item
”数组,而不是productname
。我不知道如何获得productname
。这是完整的代码。
<?php
require_once('app/Mage.php');
Mage::app();
$orders = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('status', 'processing')
->addAttributeToSelect('customer_email')
->addAttributeToSelect('status')
;
foreach ($orders as $order) {
$email = $order->getCustomerEmail();
$customername = $order->getCustomerName();
$product = Mage::getModel('sales/order')->loadByIncrementID($order_id);
$items = $order->getAllItems();
$itemcount=count($items);
$name=array();
$sku=array();
$ids=array();
$qty=array();
foreach ($items as $itemId => $item)
{
$name[]=$item->getName();
$sku[]=$item->getSku();
$ids[]=$item->getProductId();
$qty[]=$item->getQtyToInvoice();
}
echo $order->getId() . ": " . $order->getStatus() . ": " . $email . ": " . $customername . ": " . $name . "<br />";
}
?>
答案 0 :(得分:0)
尝试
$item->getProduct()->getName()
如果不起作用请尝试:
$product = Mage::getModel('catalog/product')->setStoreId($order->getStoreId())->load($item->getProductId());
$name = $product->getName();