我创建了一个允许预订产品的自定义模块
这是我的安装脚本
<?php
$this->startSetup();
$this->addAttribute('catalog_product', 'pre_order', array(
'group' => 'General',
'type' => 'int', // can be int, varchar, decimal, text, datetime
'backend' => '', // If you're making an image attribute you'll need to add : catalog/category_attribute_backend_image
'frontend_input' => '',
'frontend' => '',
'label' => 'Is Pre Order',
'input' => 'boolean', //text, textarea, select, file, image, multiselect
'class' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // Scope can be SCOPE_STORE, SCOPE_GLOBAL or SCOPE_WEBSITE
'visible' => true,
'frontend_class' => '',
'required' => false, // or true
'user_defined' => true, // or false
'used_in_product_listing' => '1',
'default' => '',
'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
));
$this->addAttribute('catalog_product', 'pre_order_note', array(
'group' => 'General',
'type' => 'varchar', // can be int, varchar, decimal, text, datetime
'backend' => '', // If you're making an image attribute you'll need to add : catalog/category_attribute_backend_image
'frontend_input' => '',
'frontend' => '',
'label' => 'Pre Order Note',
'input' => 'text', //text, textarea, select, file, image, multiselect
'class' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, // Scope can be SCOPE_STORE, SCOPE_GLOBAL or SCOPE_WEBSITE
'visible' => true,
'frontend_class' => '',
'required' => false, // or true
'user_defined' => true, // or false
'used_in_product_listing' => '1',
'default' => '',
'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
));
$this->endSetup();
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
/**
* Add 'custom_attribute' attribute for entities
*/
$entities = array(
'quote',
'quote_item',
'order',
'order_item'
);
$entitiesnew = array(
'quote_item',
'order_item'
);
$options = array(
'type' => Varien_Db_Ddl_Table::TYPE_BOOLEAN,
'visible' => true,
'required' => false,
'default' => 0
);
$options2 = array(
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
'visible' => true,
'required' => false
);
foreach ($entities as $entity) {
$installer->addAttribute($entity, 'pre_order', $options);
}
foreach ($entitiesnew as $entitynew) {
$installer->addAttribute($entitynew, 'pre_order_note', $options2);
}
$installer->endSetup();
?>
但问题是当我尝试在管理面板中访问sales-&gt;订单时,我想出了错误
未找到列:1054未知列&#39; salesorder.pre_order&#39;在&#39;字段列表&#39;中,查询为:SELECT main_table
。*,salesorder
。pre_order
FROM mgpm_sales_flat_order_grid
AS main_table
LEFT JOIN mgpm_sales_flat_order
AS salesorder
ON salesorder.entity_id = mgpm_main_table.entity_id ORDER BY main_table.created_at DESC LIMIT
这是我的AdminHtml销售订单网格块
<?php
class Vishwasnature_Preorder_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid {
public function __construct()
{
parent::__construct();
$this->setId('sales_order_grid');
$this->setUseAjax(true);
$this->setDefaultSort('created_at');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
}
/**
* Retrieve collection class
*
* @return string
*/
protected function _getCollectionClass()
{
return 'sales/order_grid_collection';
}
protected function _prepareCollection()
{
$tablePrefix = (string) Mage::getConfig()->getTablePrefix();
$collection = Mage::getResourceModel($this->_getCollectionClass());
$collection->getSelect()->joinleft(array('salesorder'=> $tablePrefix . 'sales_flat_order'),'salesorder.entity_id =' .$tablePrefix . 'main_table.entity_id',array('pre_order' => 'salesorder.pre_order'));
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('pre_order', array(
'header' => Mage::helper('sales')->__('Order Type'),
'index' => 'pre_order',
'filter_index' => 'salesorder.pre_order',
'type' => 'options',
'width' => '70px',
'options' => Mage::getSingleton('preorder/observer')->getOrderTypes(),
));
$this->addColumn('status', array(
'header' => Mage::helper('sales')->__('Status'),
'index' => 'status',
'type' => 'options',
'width' => '70px',
'filter_index' => 'main_table.status',
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
));
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
$this->addColumn('action',
array(
'header' => Mage::helper('sales')->__('Action'),
'width' => '50px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('sales')->__('View'),
'url' => array('base'=>'*/sales_order/view'),
'field' => 'order_id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
'is_system' => true,
));
}
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
return parent::_prepareColumns();
}
protected function _prepareMassaction()
{
$this->setMassactionIdField('entity_id');
$this->getMassactionBlock()->setFormFieldName('order_ids');
$this->getMassactionBlock()->setUseSelectAll(false);
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
$this->getMassactionBlock()->addItem('cancel_order', array(
'label'=> Mage::helper('sales')->__('Cancel'),
'url' => $this->getUrl('*/sales_order/massCancel'),
));
}
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
$this->getMassactionBlock()->addItem('hold_order', array(
'label'=> Mage::helper('sales')->__('Hold'),
'url' => $this->getUrl('*/sales_order/massHold'),
));
}
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
$this->getMassactionBlock()->addItem('unhold_order', array(
'label'=> Mage::helper('sales')->__('Unhold'),
'url' => $this->getUrl('*/sales_order/massUnhold'),
));
}
$this->getMassactionBlock()->addItem('pdfinvoices_order', array(
'label'=> Mage::helper('sales')->__('Print Invoices'),
'url' => $this->getUrl('*/sales_order/pdfinvoices'),
));
$this->getMassactionBlock()->addItem('pdfshipments_order', array(
'label'=> Mage::helper('sales')->__('Print Packingslips'),
'url' => $this->getUrl('*/sales_order/pdfshipments'),
));
$this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
'label'=> Mage::helper('sales')->__('Print Credit Memos'),
'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
));
$this->getMassactionBlock()->addItem('pdfdocs_order', array(
'label'=> Mage::helper('sales')->__('Print All'),
'url' => $this->getUrl('*/sales_order/pdfdocs'),
));
$this->getMassactionBlock()->addItem('print_shipping_label', array(
'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
));
return $this;
}
public function getRowUrl($row)
{
if (Mage::getSingleton('admin/session')->isAllowed ('sales/order/actions/view')) {
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
}
return false;
}
public function getGridUrl()
{
return $this->getUrl('*/*/grid', array('_current'=>true));
}
}
?>
你能指出问题吗?
谢谢,