CLosed 我可以做到,我混合了 2 个答案的代码来制作我的页面
我想使用我的自定义数据库表制作特殊订单页面
我可以像这样创建新的 magento 管理员页面布局吗
我想要像这个页面这样的布局
我想展示
订单订单日期 客户 ID 客户公司 SKU 产品名称 数量, 总状态操作
并且我的数据库表名是特殊顺序在表中的字段中有
order_no PK (from product id)
order_item_number PK (to show in Orders)
creat_date (to show in OrdersDate)
Cusid (to show in CustomerID)
Cusname (to show in CustomerCompany)
sku (to show in SKU)
Productname (to show in ProductName )
price
qty (to show in Qty,)
total_price (to show in Total)
status (to show in Status)
表中的数据如下所示 (order_no + order_item_no = pk(
11 日期 cusid cusname SKU P.name 价格 数量 总状态
2 1 日期 cusid cusname SKU P.name 价格 数量 总状态
22 日期 cusid cusname SKU P.name 价格 数量 总状态
如何使用此表显示在我的自定义管理页面中
管理面板中使用自定义表创建模块。
在本地目录(app/code/local/Pfay/Test(中创建模块,其中test -> .在这个结构内创建所有这些目录 助手等,块,模型,控制器
让我们从 etc 创建配置文件开始.xml文件:
<?xml version="1.0"?>
<config>
<modules>
<Pfay_Test>
<version>1.0.0</version>
</Pfay_Test>
</modules>
<global>
<blocks>
<test>
<class>Pfay_Test_Block</class>
</test>
</blocks>
<models>
<test>
<class>Pfay_Test_Model</class>
<resourceModel>test_mysql4</resourceModel>
</test>
<test_mysql4>
<class>Pfay_Test_Model_Mysql4</class>
<entities>
<test>
<table>pfay_test</table>
</test>
</entities>
</test_mysql4>
</models>
<!-- allow the plugin to read and write -->
<resources>
<!-- connection to write -->
<test_write>
<connection>
<use>core_write</use>
</connection>
</test_write>
<!-- connection to read -->
<test_read>
<connection>
<use>core_read</use>
</connection>
</test_read>
</resources>
<!-- -/- -->
</global>
<frontend>
<routers>
<routeurfrontend>
<use>standard</use>
<args>
<module>Pfay_Test</module>
<frontName>test</frontName>
</args>
</routeurfrontend>
</routers>
<layout>
<updates>
<test>
<file>test.xml</file>
</test>
</updates>
</layout>
</frontend>
<admin>
<routers>
<test>
<use>admin</use>
<args>
<module>Pfay_Test</module>
<frontName>admintest</frontName>
</args>
</test>
</routers>
</admin>
<adminhtml>
<layout>
<updates>
<test>
<file>test.xml</file>
</test>
</updates>
</layout>
<menu>
<test translate="title" module="adminhtml">
<title>Import XLS</title>
<sort_order>100</sort_order>
<children>
<set_time>
<title>Add product through XLS</title>
<action>admintest/adminhtml_index</action>
</set_time>
</children>
</test>
</menu>
</adminhtml>
</config>
我的表名是Pfay_test添加您的表名,而不是这个。
现在在控制器中创建目录 Adminhtml 在此创建中创建您的控制器索引控制器.php
<?php
class Pfay_Test_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
protected function _initAction()
{
$this->loadLayout()->_setActiveMenu('test/set_time')
->_addBreadcrumb('test Manager','test Manager');
return $this;
}
public function indexAction()
{
$this->_initAction();
$this->renderLayout();
}
}
其中set_time您在 config.xml 文件中添加的菜单名称。
现在移动到您的块部分,您将在其中创建网格。在块目录中创建Adminhtml > Grid.php
class Pfay_Test_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
//where is the controller
$this->_controller = 'adminhtml_test';
$this->_blockGroup = 'test';
//text in the admin header
$this->_headerText = 'XLS file management';
//value of the add button
parent::__construct();
}
}
接下来创建一个目录测试>网格.php
<?php
class Pfay_Test_Block_Adminhtml_Test_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('contactGrid');
$this->setDefaultSort('id_pfay_test');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$collection = Mage::getModel('test/test')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('id_pfay_test',
array(
'header' => 'ID',
'align' =>'right',
'width' => '50px',
'index' => 'id_pfay_test',
));
$this->addColumn('nom',
array(
'header' => 'nom',
'align' =>'left',
'index' => 'nom',
));
$this->addColumn('prenom', array(
'header' => 'prenom',
'align' =>'left',
'index' => 'prenom',
));
$this->addColumn('telephone', array(
'header' => 'telephone',
'align' =>'left',
'index' => 'telephone',
));
return parent::_prepareColumns();
}
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
}
}
现在转到您的模型内部模型创建测试.php和Mysql4
在测试中.php :
<?php
class Pfay_Test_Model_Test extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('test/test');
}
}
这里(测试/测试(是Pfay_<modulename>_Model_<modulename> -> (<modulename>/<modulename>)
现在Pfay > Test > Model > Mysql4
文件夹中创建测试.php和测试
在测试中.php :
<?php
class Pfay_Test_Model_Mysql4_Test extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
$this->_init('test/test', 'id_pfay_test');
}
}
其中id_pfay_test是表的唯一键。
Pfay >Test >Model >Mysql4 >Test > create a file Collection.php
<?php
class Pfay_Test_Model_Mysql4_Test_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('test/test');
}
}
最后一步通知magento您的模块:创建文件Pfay_Test.xml
/app/etc/modules
<?xml version="1.0"?>
<config>
<modules>
<Pfay_Test>
<active>true</active>
<codePool>local</codePool>
</Pfay_Test>
</modules>
</config>
注意:根据您的情况更改模块名称和软件包名称。
如果您对此有任何疑问,请随时。
尝试使用内置的Magento Grid。为了不重复内容,请尝试以下操作:
- http://inchoo.net/magento/how-to-create-a-custom-grid-from-scratch/