Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 创建剪切顺序属性不起作用_Magento - Fatal编程技术网

Magento 创建剪切顺序属性不起作用

Magento 创建剪切顺序属性不起作用,magento,Magento,我需要创建自定义订单属性。我尝试了下面的代码。运行后,“代码”属性不会作为新列显示在sales\u flat\u order表中 <?php $installer = $this; $installer->startSetup(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $setup->addAttribute('order', 'newfield1', array( 'type'

我需要创建自定义订单属性。我尝试了下面的代码。运行后,“代码”属性不会作为新列显示在
sales\u flat\u order
表中

<?php
$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('order', 'newfield1', array(
    'type'              => 'int',
    'global'            => 0,
    'visible'           => 0,
    'required'          => 0,
    'user_defined'      => 0,
    'searchable'        => 0,
    'filterable'        => 0,
    'comparable'        => 0,
    'visible_on_front'  => 0,
    'visible_in_advanced_search' => 0,
    'unique'            => 0,
    'is_configurable'   => 0,
    'default'           => 0,
));
$installer->endSetup();
错误: 注意:会话已启动-忽略第125行C:\xampp\htdocs\abcproject\app\code\core\Mage\core\Model\session\Abstract\Varien.php中的会话\u start()

谁能帮我解决这个问题。谁能告诉我我做错了什么


谢谢您检查此项。尝试在系统上创建相同的目录,这将创建一个名为“customfield”的新销售订单属性

app/code/local/Knkm/Orderattribute/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Knkm_Orderattribute>
      <version>0.1.0</version>
    </Knkm_Orderattribute>
  </modules>
  <global>
    <helpers>
      <orderattribute>
        <class>Knkm_Orderattribute_Helper</class>
      </orderattribute>
    </helpers>
    <models>
      <orderattribute>
        <class>Knkm_Orderattribute_Model</class>
        <resourceModel>orderattribute_mysql4</resourceModel>
      </orderattribute>
    </models>
    <resources>
      <salesattribute1446018370_setup>
        <setup>
          <module>Knkm_Orderattribute</module>
          <class>Mage_Sales_Model_Mysql4_Setup</class>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </salesattribute1446018370_setup>
      <salesattribute1446018370_write>
        <connection>
          <use>core_write</use>
        </connection>
      </salesattribute1446018370_write>
      <salesattribute1446018370_read>
        <connection>
          <use>core_read</use>
        </connection>
      </salesattribute1446018370_read>
    </resources>
  </global>
</config> 

0.1.0
Knkm_Orderattribute_辅助程序
Knkm_Orderattribute_模型
orderattribute_mysql4
Knkm_Orderattribute
Mage_销售_型号_Mysql4_设置
核心单元设置
核心写入
核心读取
app/code/local/Knkm/Orderattribute/Helper/Data.php

<?php
class Knkm_Orderattribute_Helper_Data extends Mage_Core_Helper_Abstract
{
}

符合事实的
地方的
0.1.0
希望这能帮到你

谢谢你试试这个

<?php require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute  = array(
'type'          => 'varchar'
'backend_type'  => 'varchar',
'frontend_input' => 'varchar',
'is_user_defined' => true,
'label'         => 'custom_label',
'visible'      => true,
'required'      => false,
'user_defined'  => false,
'searchable'    => false,
'filterable'    => false,
'comparable'    => false,
'default'       => ''
);
$installer->addAttribute('order', 'custom_attribute', $attribute);
$installer->addAttribute('quote', 'custom_attribute', $attribute);
$installer->endSetup();

echo 'success';

<?php
$installer = $this;
$installer->startSetup();

$installer->addAttribute("order", "customfield", array("type"=>"varchar"));
$installer->endSetup();
<?xml version="1.0"?>
<config>
  <modules>
    <Knkm_Orderattribute>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </Knkm_Orderattribute>
  </modules>
</config>
<?php require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute  = array(
'type'          => 'varchar'
'backend_type'  => 'varchar',
'frontend_input' => 'varchar',
'is_user_defined' => true,
'label'         => 'custom_label',
'visible'      => true,
'required'      => false,
'user_defined'  => false,
'searchable'    => false,
'filterable'    => false,
'comparable'    => false,
'default'       => ''
);
$installer->addAttribute('order', 'custom_attribute', $attribute);
$installer->addAttribute('quote', 'custom_attribute', $attribute);
$installer->endSetup();

echo 'success';