0

Magento エキスパートの皆様、こんにちは。

Magento Extensionで正常に動作する を開発しましたVersion 1.6 and 1.7が、 にインストールするとVersion 1.5エラーが発生します:

Fatal error: Call to a member function getData() on a non-object in /home/broadcas/public_html/app/code/community/Gwb/Magecrmsync/controllers/Adminhtml/OrdersController.php on line 18

以下は私のOrderController.phpコードです。

<?php
class Gwb_Magecrmsync_Adminhtml_OrdersController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
    $model = Mage::getModel('sales/order');

    $collection = $model->getCollection()
    ->addFieldToFilter('status', array("in" => array('complete','closed','pending','holded','payment_review','pending_payment','pending_paypal','processing')));

    $data = array();
    $orderArr = array();

    // getting order details

    $records = 0;
    foreach($collection as $order)
    {
        $data[$records]['order_data']['shipping_address'] = $order->getShippingAddress()->getData(); // get shipping details
        $data[$records]['order_data']['billing_address'] = $order->getBillingAddress()->getData(); // get billing details
        $data[$records]['order_data']['order_total'] = $order->getGrandTotal(); // get total amount
        $data[$records]['order_data']['shipping_amount'] = $order->getShippingAmount();
        $data[$records]['order_data']['order_details'] = $order->toArray();
        $records++;
    }

    // getting order details

}
}

で動作しない間違っていることを教えてくださいVersion 1.5

どんな助けでも大歓迎です。

ありがとう

4

1 に答える 1

1

私の答えを確認してください。$order->getShippingAddress()オブジェクトかどうかを確認する必要があります。製品が仮想の場合。配送先が設定されます。

class Gwb_Magecrmsync_Adminhtml_OrdersController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
    $model = Mage::getModel('sales/order');

    $collection = $model->getCollection()
    ->addFieldToFilter('status', array("in" => array('complete','closed','pending','holded','payment_review','pending_payment','pending_paypal','processing')));

    $data = array();
    $orderArr = array();
    // getting order details
    $records = 0;
    foreach($collection as $order)
    {

            if(is_object($order->getShippingAddress()))
            {    
                $data[$records]['order_data']['shipping_address'] = $order->getShippingAddress()->getData(); // get shipping details
            }    
            else
            {
                $data[$records]['order_data']['shipping_address'] = array(); // no shipping details
            }

            if(is_object($order->getBillingAddress()))
            {
                $data[$records]['order_data']['billing_address'] = $order->getBillingAddress()->getData(); // get billing details
            }
            else
            {
                $data[$records]['order_data']['billing_address'] = array(); // no billing details    
            }

            $data[$records]['order_data']['order_total'] = $order->getGrandTotal(); // get total amount
            $data[$records]['order_data']['shipping_amount'] = $order->getShippingAmount();
            $data[$records]['order_data']['order_details'] = $order->toArray();
              $records++;
    }

    // getting order details

}
}
于 2013-03-19T07:34:05.830 に答える