2015-02-07 142 views
0

我正在使用Mangento 1.9.0.1。Magento - 尝试创建新的Adminhtml网格表时出错

我工作的一个新的自定义扩展,这是我迄今所做的:

/app/code/community/VivasIndustries/SmsNotification/etc/config.xml:

<?xml version="1.0"?> 
<config> 
    <modules> 
    <VivasIndustries_SmsNotification> 
     <version>0.1.0</version> 
    </VivasIndustries_SmsNotification> 
    </modules> 
    <global> 
    <models> 
     <smsnotification> 
      <class>VivasIndustries_SmsNotification_Model</class> 
      <resourceModel>vivasindustries_smsnotification_resource</resourceModel> 
     </smsnotification> 
    </models> 
    <resources> 
     <smsnotification_setup> 
      <setup> 
       <module>VivasIndustries_SmsNotification</module> 
      </setup> 
     </smsnotification_setup> 
    </resources>  
    <events> 
     <sales_order_save_after> 
      <observers> 
       <vivasindustries_smsnotification> 
        <class>smsnotification/observer</class> 
        <method>orderSaved</method> 
       </vivasindustries_smsnotification> 
      </observers> 
     </sales_order_save_after> 
    </events> 
    <helpers> 
     <smsnotification> 
      <class>VivasIndustries_SmsNotification_Helper</class> 
     </smsnotification> 
    </helpers> 
    <blocks> 
     <smsnotification> 
      <class>VivasIndustries_SmsNotification_Block</class> 
     </smsnotification> 
    </blocks> 
    </global> 
    <adminhtml> 
    <acl> 
     <resources> 
      <all> 
       <title>Allow Everything</title> 
      </all> 
      <admin> 
       <children> 
        <system> 
         <children> 
          <config> 
           <children> 
            <vivas> 
             <title>Vivas - All</title> 
            </vivas> 
           </children> 
          </config> 
         </children> 
        </system> 
       </children> 
      </admin> 
     </resources> 
    </acl> 
    </adminhtml> 
    <admin> 
     <routers> 
      <adminhtml> 
       <args> 
        <modules> 
         <VivasIndustries_SmsNotification before="Mage_Adminhtml">VivasIndustries_SmsNotification_Adminhtml</VivasIndustries_SmsNotification> 
        </modules> 
       </args> 
      </adminhtml> 
     </routers> 
    </admin> 
</config> 

以下是我在/app/code/community/VivasIndustries/SmsNotification/etc/adminhtml.xml:

<?xml version="1.0"?> 
<config> 
    <menu> 
     <vivassms translate="title" module="smsnotification"> 
      <title>SMS Center</title> 
      <sort_order>110</sort_order> 
      <children> 

       <settings> 
        <title>Settings</title> 
        <action>adminhtml/system_config/edit/section/vivas/</action> 
        <sort_order>10</sort_order> 
       </settings> 
       <smsorderstatuses translate="title" module="smsnotification"> 
        <title>SMS on Order Statuses</title> 
        <action>adminhtml/smsorderstatuses</action> 
        <sort_order>11</sort_order> 
       </smsorderstatuses> 
       <about translate="title" module="smsnotification"> 
        <title>About</title> 
        <action>adminhtml/about</action> 
        <sort_order>12</sort_order> 
       </about> 
      </children> 
     </vivassms> 
    </menu> 
    <acl> 
     <resources> 
      <admin> 
       <children> 
        <vivassms> 
         <title>SMS</title> 
         <children> 
          <sendsms translate="title" module="smsnotification"> 
           <title>Send SMS</title> 
          </sendsms> 
          <settings> 
           <title>Settings</title> 
           <children> 
            <smsprofile translate="title" module="smsnotification"> 
             <title>Edit user account</title> 
            </smsprofile> 
           </children> 
          </settings> 
          <smsorderstatuses translate="title" module="smsnotification"> 
           <title>SMS on Order Statuses</title> 
          </smsorderstatuses> 
          <about translate="title" module="smsnotification"> 
           <title>About</title> 
          </about> 
         </children> 
        </vivassms> 
        <system> 
         <children> 
          <config> 
           <children> 
            <vivassms translate="title" module="smsnotification"> 
             <title>Vivas SMS</title> 
            </vivassms> 
           </children> 
          </config> 
         </children> 
        </system> 
       </children> 
      </admin> 
     </resources> 
    </acl> 
</config> 

这里是我在:/应用程序/代码/社区/ VivasIndustries/SMS通知/座/ Adminh TML /销售/ Grid.php:

<?php 

class VivasIndustries_SmsNotification_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
     $this->setId('smsnotification_grid'); 
     $this->setDefaultSort('increment_id'); 
     $this->setDefaultDir('DESC'); 
     $this->setSaveParametersInSession(true); 
     $this->setUseAjax(true); 
    } 

    protected function _prepareCollection() 
    { 
     $collection = Mage::getResourceModel('sales/order_collection') 
      ->join(array('a' => 'sales/order_address'), 'main_table.entity_id = a.parent_id AND a.address_type != \'billing\'', array(
       'city'  => 'city', 
       'country_id' => 'country_id' 
      )) 
      ->join(array('c' => 'customer/customer_group'), 'main_table.customer_group_id = c.customer_group_id', array(
       'customer_group_code' => 'customer_group_code' 
      )) 
      ->addExpressionFieldToSelect(
       'fullname', 
       'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})', 
       array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname')) 
      ->addExpressionFieldToSelect(
       'products', 
       '(SELECT GROUP_CONCAT(\' \', x.name) 
        FROM sales_flat_order_item x 
        WHERE {{entity_id}} = x.order_id 
         AND x.product_type != \'configurable\')', 
       array('entity_id' => 'main_table.entity_id') 
      ) 
     ; 

     $this->setCollection($collection); 
     parent::_prepareCollection(); 
     return $this; 
    } 

    protected function _prepareColumns() 
    { 
     $helper = Mage::helper('smsnotification'); 
     $currency = (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE); 

     $this->addColumn('increment_id', array(
      'header' => $helper->__('Order #'), 
      'index' => 'increment_id' 
     )); 

     $this->addColumn('purchased_on', array(
      'header' => $helper->__('Purchased On'), 
      'type' => 'datetime', 
      'index' => 'created_at' 
     )); 

     $this->addColumn('products', array(
      'header'  => $helper->__('Products Purchased'), 
      'index'  => 'products', 
      'filter_index' => '(SELECT GROUP_CONCAT(\' \', x.name) FROM sales_flat_order_item x WHERE main_table.entity_id = x.order_id AND x.product_type != \'configurable\')' 
     )); 

     $this->addColumn('fullname', array(
      'header'  => $helper->__('Name'), 
      'index'  => 'fullname', 
      'filter_index' => 'CONCAT(customer_firstname, \' \', customer_lastname)' 
     )); 

     $this->addColumn('city', array(
      'header' => $helper->__('City'), 
      'index' => 'city' 
     )); 

     $this->addColumn('country', array(
      'header' => $helper->__('Country'), 
      'index' => 'country_id', 
      'renderer' => 'adminhtml/widget_grid_column_renderer_country' 
     )); 

     $this->addColumn('customer_group', array(
      'header' => $helper->__('Customer Group'), 
      'index' => 'customer_group_code' 
     )); 

     $this->addColumn('grand_total', array(
      'header'  => $helper->__('Grand Total'), 
      'index'   => 'grand_total', 
      'type'   => 'currency', 
      'currency_code' => $currency 
     )); 

     $this->addColumn('shipping_method', array(
      'header' => $helper->__('Shipping Method'), 
      'index' => 'shipping_description' 
     )); 

     $this->addColumn('order_status', array(
      'header' => $helper->__('Status'), 
      'index' => 'status', 
      'type' => 'options', 
      'options' => Mage::getSingleton('sales/order_config')->getStatuses(), 
     )); 

     $this->addExportType('*/*/exportInchooCsv', $helper->__('CSV')); 
     $this->addExportType('*/*/exportInchooExcel', $helper->__('Excel XML')); 

     return parent::_prepareColumns(); 
    } 

    public function getGridUrl() 
    { 
     return $this->getUrl('*/*/grid', array('_current'=>true)); 
    } 
} 

这里是我有:/public_html/store/app/code/community/VivasIndustries/SmsNotification/Block/Adminhtml/Sales/Order.php:

<?php 

class VivasIndustries_SmsNotification_Block_Adminhtml_Sales_Order extends Mage_Adminhtml_Block_Widget_Grid_Container 
{ 
    public function __construct() 
    { 
     $this->_blockGroup = 'smsnotification'; 
     $this->_controller = 'adminhtml_sales_order'; 
     $this->_headerText = Mage::helper('smsnotification')->__('Orders - Inchoo'); 

     parent::__construct(); 
     $this->_removeButton('add'); 
    } 
} 

当我在管理面板去点击SMS on Order Statuses我碰到下面的错误报告:http://inchoo.net/magento/how-to-create-a-custom-grid-from-scratch/

a:5:{i:0;s:51:"Controller file was loaded but class does not exist";i:1;s:1078:"#0 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(327): Mage::exception('Mage_Core', 'Controller file...') 
#1 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(294): Mage_Core_Controller_Varien_Router_Standard->_includeControllerClass('/home/superweb/...', 'VivasIndustries...') 
#2 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(196): Mage_Core_Controller_Varien_Router_Standard->_validateControllerClassName('VivasIndustries...', 'smsorderstatuse...') 
#3 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) 
#4 /home/superweb/public_html/store/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() 
#5 /home/superweb/public_html/store/app/Mage.php(684): Mage_Core_Model_App->run(Array) 
#6 /home/superweb/public_html/store/index.php(87): Mage::run('', 'store') 
#7 {main}";s:3:"url";s:77:"/index.php/admin/smsorderstatuses/index/key/1eb60b827b45e2c2a28bc73d31b1ba27/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";} 

我这个指南所做的一切

你能帮我解决这个问题,并帮助我了解我的错误在哪里吗?

我张贴,我得到了,当我尝试打开该页面错误的图像:

enter image description here

回答

0

从已粘贴错误:

a:5:{i:0;s:51:"Controller file was loaded but class does not exist";i:1;s:1078:"#0 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(327): Mage::exception('Mage_Core', 'Controller file...') 
#1 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(294): Mage_Core_Controller_Varien_Router_Standard->_includeControllerClass('/home/superweb/...', 'VivasIndustries...') 
#2 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(196): Mage_Core_Controller_Varien_Router_Standard->_validateControllerClassName('VivasIndustries...', 'smsorderstatuse...') 
#3 /home/superweb/public_html/store/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) 
#4 /home/superweb/public_html/store/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() 
#5 /home/superweb/public_html/store/app/Mage.php(684): Mage_Core_Model_App->run(Array) 
#6 /home/superweb/public_html/store/index.php(87): Mage::run('', 'store') 
#7 {main}";s:3:"url";s:77:"/index.php/admin/smsorderstatuses/index/key/1eb60b827b45e2c2a28bc73d31b1ba27/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";} 

它调用清楚地显示“控制器文件已加载但类别不存在”

这意味着基于以下URL:/ admin/smsorderstatuses/index

你需要创建一个文件:/app/code/community/VivasIndustries/SmsNotification/controllers/Adminhtml/SmsorderstatusesController.php

在这里写如下的功能测试:

public function indexAction() 
{ 
    $this->loadLayout()->renderLayout(); 
} 

你已经完成了以上确保此文件后:/app/code/community/VivasIndustries/SmsNotification/etc/config.xml包含<frontend><routers></routers></frontend>如下:

<frontend> 
<!-- ... --> 

<routers> 
    <smsnotification> 
     <use>standard</use> 
     <args> 
      <module>VivasIndustries_SmsNotification</module> 
      <frontName>smsorderstatuses</frontName> 
     </args> 
    </smsnotification> 
</routers> 

<!-- ... --> 
</frontend> 

希望这会有所帮助。让我知道这是否适合你。

快乐编码...

相关问题