乔纳森日说
"更新不应该以SQL命令的形式".我没有遇到任何无法通过Magento配置结构执行的DDL或DML语句.
(在问题中如何将配置更改从开发迁移到生产环境?)
我想知道如何以这种方式向表中添加/修改/删除列或索引,但不依赖于SQL?它甚至可能吗?
此外,还有哪些其他操作只能在SQL中完成?
我想知道在magento(1.4.1.1)中向支付添加一些信息的更好方法是哪种.
假设我想添加一个名为"payment_duedate"的信息,该信息将是客户支付发票的日期.
实际上,sales_flat_order_payment中有一个名为"additional_information"的字段,其中包含方法setAdditionalInformation($ arg1,$ arg2)设置的序列化数据; 可在"销售/付款"模式中使用.所以我可以通过以下方式保存日期:
$payment->setAdditionalInformation('payment_duedate',$myDate);
$payment->save();
Run Code Online (Sandbox Code Playgroud)
但是也可以选择添加支付属性,这样可以在'sales_flat_order_payment'中创建一个名为'payment_duedate'的新列,然后通过执行以下操作来保存我的日期:
$payment->setPaymentDuedate($myDate);
$payment->save();
Run Code Online (Sandbox Code Playgroud)
主要区别是:
那么,在您看来,这两种方式中哪一种最好?
谢谢,Hugues.
我正在关注Ivan的教程(将订单属性添加到Magento 1.4.1中的订单网格)以向sales_order_grid表(Shipping Description文本)添加一个额外的列,并且它正在工作,除了它不会将sales_flat_order中的旧数据带到新列在sales_order_grid中.
我的SQL安装脚本正确地添加了列,因为我使用与sales_flat_order中相同的字段名称我认为我不需要观察者,但是将所有现有出货描述数据导入到shipping_description字段的代码不是运行.
我做错了什么?
我的SQL安装脚本:
<?php
/**
* Setup scripts, add new column and fulfills
* its values to existing rows
*
*/
/* @var $this Mage_Sales_Model_Mysql4_Setup */
$this->startSetup();
// Add column to grid table
$this->getConnection()->addColumn(
$this->getTable('sales/order_grid'),
'shipping_description',
"varchar(255) not null default ''"
);
// Add key to table for this field,
// it will improve the speed of searching & sorting by the field
$this->getConnection()->addKey(
$this->getTable('sales/order_grid'),
'shipping_description',
'shipping_description'
);
// fill existing rows with data
$select …Run Code Online (Sandbox Code Playgroud)