Collections foreach使用Opencart在collection.tpl文件中显示NULL

Collections foreach使用Opencart在collection.tpl文件中显示NULL,collections,foreach,opencart,Collections,Foreach,Opencart,我正在尝试将数组值传递到collection.tpl文件。但它显示NULL值 但在控制器中,我编写代码var_dump($this->data['collections')在页面顶部显示一些数组值。这一结果正在发生 数组(1){[0]=>数组(8){[“发票id”]=>字符串(4)”1088”[“交货点名称”]=>字符串(9)”Peelamedu”[“总计”]=>字符串(4)”1253”[“收款金额”=>字符串(4)”1000”[“付款类型”=>字符串(7)“部分”[“付款方式”=>字符串(4)

我正在尝试将
数组
值传递到collection.tpl文件。但它显示
NULL

但在控制器中,我编写代码
var_dump($this->data['collections')在页面顶部显示一些数组值。这一结果正在发生

数组(1){[0]=>数组(8){[“发票id”]=>字符串(4)”1088”[“交货点名称”]=>字符串(9)”Peelamedu”[“总计”]=>字符串(4)”1253”[“收款金额”=>字符串(4)”1000”[“付款类型”=>字符串(7)“部分”[“付款方式”=>字符串(4)”现金”[“状态”=>字符串(4)”已付款”[“日期时间”=>字符串(19)”2017-05-05:14}

下面是我的代码:invoice.php

public function collection()
{
        $this->load->language('account/account');
        $data['breadcrumbs'] = array();

        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('Home'),
            'href' => $this->url->link('common/home')
        );
        $data['breadcrumbs'][] = array(
            'text' => $this->language->get('Previous'),
            'href' => $this->url->link('account/invoice', '', 'SSL')
        );
        $this->load->model('account/add_invoice');

        //$data['action'] = $this->url->link('account/invoice/collection', '', 'SSL');
        $this->data['action'] = $this->url->link('account/invoice/collection', '', 'SSL');


       $invoiceId='';
        if(isset($_GET['invoice_id']))
        {
            $invoiceId=$_GET['invoice_id'];
        }

        $data['invoice']=array();


        $data['invoice_id']=$invoiceId;

        $data['products']=$this->getProduct();
        $data['units']=['Boxes','Pieces','Kg'];

        $data['delivery_point']=$this->getDeliveryPoint();
        $data['status']=['Enabled','Disabled'];



        $data['invoiceProduct']=$this->model_account_add_invoice->getProductByInvoiceId($invoiceId);
        $data['totalPriceData']=$this->model_account_add_invoice->getTotalPriceByInvoiceId($invoiceId);

        $invoiceDeliveryPointold=$this->model_account_add_invoice->getInvoiceDeliveryPoint($invoiceId);

        $query=$this->db->query("SELECT delivery_point_name,invoice_id FROM ".DB_PREFIX."invoice_delivery_point where invoice_id=".$invoiceId);

        $invoiceDeliveryPoint=$query->row['delivery_point_name'];
        $data['invoiceDeliveryPoint']=$invoiceDeliveryPoint;


        $query=$this->db->query("SELECT i.date_added,concat(c.firstname,' ',c.lastname) as name,c.tin_number,c.invoice_no_overwrite,i.invoice_id FROM ".DB_PREFIX."invoice i left join ".DB_PREFIX."customer c on i.customer_id=c.customer_id where i.invoice_id=".$invoiceId);
        $data['invoiceData']=$query->rows;

        $invoiceDeliveryPoint=$query->row['delivery_point_name'];
        $invoice_id = $query->row['invoice_id'];

         /*view collection*/
        $query22 = $this->db->query("select * from ".DB_PREFIX."collection where invoice_id='".$invoice_id."'");
        $show_collection = $query22->rows;
        foreach($show_collection as $collections)
        {
            $this->data['collections'][] = array(
                'invoice_id' => $collections['invoice_id'],
                'delivery_point_name' =>$collections['delivery_point_name'],
                'total' =>$collections['total'],
                'collection_amount' =>$collections['collection_amount'],
                'payment_type' =>$collections['payment_type'],
                'payment_mode' =>$collections['payment_mode'],
                'status' =>$collections['status'],
                'datetime' =>$collections['datetime']
                );
        }
        var_dump($this->data['collections']);
        /*view collection*/

        $data['column_left'] = $this->load->controller('common/column_left');
        $data['column_right'] = $this->load->controller('common/column_right');
        $data['content_top'] = $this->load->controller('common/content_top');
        $data['content_bottom'] = $this->load->controller('common/content_bottom');
        $data['footer'] = $this->load->controller('common/footer');
        $data['header'] = $this->load->controller('common/header');

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/collection.tpl')) {
            $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/account/collection.tpl', $data));
        } else {
            $this->response->setOutput($this->load->view('default/template/account/collection.tpl', $data));
        }

        /*Insert collection datas*/
        if ($this->request->server['REQUEST_METHOD'] == 'POST')
        {   
            $invoice_id = $_POST['invoice_id'];
            $delivery_point = $_POST['delivery_point'];
            $total = $_POST['total'];
            $collection_amount = $_POST['collection_amount'];
            $payment_type = $_POST['payment_type'];
            $payment_mode = $_POST['payment_mode'];
            $status = $_POST['status'];

            $query = $this->db->query("insert into ".DB_PREFIX."collection (invoice_id,delivery_point_name,total,collection_amount,payment_type,payment_mode,status,datetime) values('".$invoice_id."','".$delivery_point."','".$total."','".$collection_amount."','".$payment_type."','".$payment_mode."','".$status."',NOW())");
            //header("Location: index.php?route=account/invoice");
        }
        /*Insert collection datas*/
}
在我的收藏中.tpl我把
它显示
NULL

我错过了什么


提前感谢……)

$this->data['collections'][]
更改为
$data['collections'][]

public function collection()
        {
            $this->load->language('account/account');
            $data['breadcrumbs'] = array();

            $data['breadcrumbs'][] = array(
                'text' => $this->language->get('Home'),
                'href' => $this->url->link('common/home')
            );
            $data['breadcrumbs'][] = array(
                'text' => $this->language->get('Previous'),
                'href' => $this->url->link('account/invoice', '', 'SSL')
            );
            $this->load->model('account/add_invoice');
            $this->data['action'] = $this->url->link('account/invoice/collection', '', 'SSL');
            $invoiceId='';
            if(isset($_GET['invoice_id']))
            {
                $invoiceId=$_GET['invoice_id'];
            }

            $data['invoice']=array();


            $data['invoice_id']=$invoiceId;

            $data['products']=$this->getProduct();
            $data['units']=['Boxes','Pieces','Kg'];

            $data['delivery_point']=$this->getDeliveryPoint();
            $data['status']=['Enabled','Disabled'];



            $data['invoiceProduct']=$this->model_account_add_invoice->getProductByInvoiceId($invoiceId);
            $data['totalPriceData']=$this->model_account_add_invoice->getTotalPriceByInvoiceId($invoiceId);

            $invoiceDeliveryPointold=$this->model_account_add_invoice->getInvoiceDeliveryPoint($invoiceId);

            $query=$this->db->query("SELECT delivery_point_name,invoice_id FROM ".DB_PREFIX."invoice_delivery_point where invoice_id=".$invoiceId);

            $invoiceDeliveryPoint=$query->row['delivery_point_name'];
            $data['invoiceDeliveryPoint']=$invoiceDeliveryPoint;


            $query=$this->db->query("SELECT i.date_added,concat(c.firstname,' ',c.lastname) as name,c.tin_number,c.invoice_no_overwrite,i.invoice_id FROM ".DB_PREFIX."invoice i left join ".DB_PREFIX."customer c on i.customer_id=c.customer_id where i.invoice_id=".$invoiceId);
            $data['invoiceData']=$query->rows;

            $invoiceDeliveryPoint=$query->row['delivery_point_name'];
            $invoice_id = $query->row['invoice_id'];


             /*view collection*/
            $query22 = $this->db->query("select * from ".DB_PREFIX."collection where invoice_id='".$invoiceId."'");
            $show_collection = $query22->rows;
            foreach($show_collection as $collections)
            {
                $data['collections'][] = array(
                    'invoice_id' => $collections['invoice_id'],
                    'delivery_point_name' =>$collections['delivery_point_name'],
                    'total' =>$collections['total'],
                    'collection_amount' =>$collections['collection_amount'],
                    'payment_type' =>$collections['payment_type'],
                    'payment_mode' =>$collections['payment_mode'],
                    'status' =>$collections['status'],
                    'datetime' =>$collections['datetime']
                    );
            }
           /*view collection*/



            $data['column_left'] = $this->load->controller('common/column_left');
            $data['column_right'] = $this->load->controller('common/column_right');
            $data['content_top'] = $this->load->controller('common/content_top');
            $data['content_bottom'] = $this->load->controller('common/content_bottom');
            $data['footer'] = $this->load->controller('common/footer');
            $data['header'] = $this->load->controller('common/header');

            if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/collection.tpl')) {
                $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/account/collection.tpl', $data));
            } else {
                $this->response->setOutput($this->load->view('default/template/account/collection.tpl', $data));
            }

            /*Insert collection datas*/
            if ($this->request->server['REQUEST_METHOD'] == 'POST')
            {   
                $invoice_id = $_POST['invoice_id'];
                $delivery_point = $_POST['delivery_point'];
                $total = $_POST['total'];
                $collection_amount = $_POST['collection_amount'];
                $payment_type = $_POST['payment_type'];
                $payment_mode = $_POST['payment_mode'];
                $status = $_POST['status'];

                $query = $this->db->query("insert into ".DB_PREFIX."collection (invoice_id,delivery_point_name,total,collection_amount,payment_type,payment_mode,status,datetime) values('".$invoice_id."','".$delivery_point."','".$total."','".$collection_amount."','".$payment_type."','".$payment_mode."','".$status."',NOW())");
                //header("Location: index.php?route=account/invoice");
            }
            /*Insert collection datas*/
    }

等等,我查一下告诉你