我想創建一個腳本,我可以通過URL訪問,以便輸出交付細節,特別是我需要顯示的字段是:orderID,status,gift_message和稱爲「delivery_instructions」的自定義客戶地址屬性。到目前爲止,我有以下內容,但我堅持試圖獲得交付說明,任何幫助將不勝感激。如何輸出Magento的傳送指令?
<?php
require_once 'app/Mage.php';
Mage::app('default');
$myOrder=Mage::getModel('sales/order');
$orders=Mage::getModel('sales/mysql4_order_collection');
$message = Mage::getModel('giftmessage/message');
$customer = Mage::getModel('customer/customer');
$orders->addFieldToFilter('total_paid',Array('gt'=>0)); //Amount paid larger than 0
//$orders->addFieldToFilter('gift_message_id',Array('gt'=>0));
$allIds=$orders->getAllIds();
foreach($allIds as $thisId) {
$myOrder->reset()->load($thisId);
$shippingAddress = $myOrder->getShippingAddress();
$customerDetails = $myOrder->getCustomer();
//echo $myOrder->shippingaddress->getData('delivery_instructions');
$customer_id = $myOrder->getCustomerId() . "',";
echo $customer_id . "',";
echo "'" . $myOrder->getStatus() . "',";
echo "'" . $myOrder->getIncrementID() . "',";
$gift_message_id = $myOrder->getGiftMessageId();
if(!is_null($gift_message_id)) {
$message->load($gift_message_id);
echo $gift_message = $message->getData('message') . "',";
};
$customer = Mage::getModel('customer/customer')->load($customer_id);
echo $customer = $customer->getData('incrementId');
echo "\r\n";
echo "<br/ >";
}
?>
感謝您的答覆。雖然這似乎獲得了字段delivery_instructions,而不是在客戶級別創建的自定義屬性。 有什麼想法? – user1461770
請參閱@ i.amniels響應...從任何對象獲取屬性如下所示:$ object-> getCamelCaseAttributeName() – FlorinelChis