将自定义字段添加到 magento 中的单页结账

发布于 2024-09-15 00:51:43 字数 730 浏览 1 评论 0原文

我正在尝试将自定义字段添加到 magento 结账页面。 我遵循了一个在 1.4.1 中不起作用的示例,因为迁移到了平面订单表(我认为)http://inchoo.net/ecommerce/magento/adding-a-new-tab-under-one-page-checkout -full-working-module/

我可以在结帐页面中看到带有自定义字段的自定义选项卡,但无法将这些字段保存到数据库中。

  • 如何向报价表和订单表添加列? 这应该转到 Mymod/sql/mymod_setup/mysql4-install-0.1.0.php 还是其他地方?

  • 如何将字段保存到数据库? 我需要先将其保存到报价单中吗? 我使用观察者还是其他什么? 我的模块的 config.xml 中是否需要有元素? http://www.magentocommerce.com/boards/viewthread/19344/< /p>

谢谢

I'm trying to add custom fields to magento checkout onepage.
I followed an example that doesn't work in 1.4.1 because of the move to a flat order table(I think) http://inchoo.net/ecommerce/magento/adding-a-new-tab-under-one-page-checkout-full-working-module/

I can see my custom tab in checkout page with my custom fields but I can't save the fields to the database.

  • How do I add columns to the quote and order tables?
    should this go to Mymod/sql/mymod_setup/mysql4-install-0.1.0.php or somewhere else?

  • How do I save the field to the db?
    Do I need to save it to the quote first?
    Do I use observer or something else?
    Do I need to have element in my module's config.xml?
    http://www.magentocommerce.com/boards/viewthread/19344/

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

为你鎻心 2024-09-22 00:51:43

免责声明:我已经 6 个月没有碰过 Magento 了。
现在就是说,如果您查看 app/code/core/Mage/Sales/sql/sales_setup/ 目录,您会找到如何修改订单表的示例。例如,这里是 app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.12-0.9.13.php 的内容(没有标题注释):

$installer = $this;
/* @var $installer Mage_Sales_Model_Mysql4_Setup */

$installer->addAttribute('quote', 'subtotal', array('type'=>'decimal'));
$installer->addAttribute('quote', 'base_subtotal', array('type'=>'decimal'));

$installer->addAttribute('quote', 'subtotal_with_discount', array('type'=>'decimal'));
$installer->addAttribute('quote', 'base_subtotal_with_discount', array('type'=>'decimal'));

$this 是根据在app/code/core/Mage/Sales/etc/config.xml 在 config/global/resources/sales_setup/setup/class 之后查看这个类,你会看到它继承自 Mage_Eav_Model_Entity_Setup(默认设置类),并覆盖或添加一些方法(例如,用于平板支持)。

要回答您的第一点(第一个问题),您可以使用此类的 addAttribute() 方法添加列。第二个问题的答案是肯定的,但是您必须在模块的 config.xml 文件中指定您想要使用 Mage_Sales_Model_Mysql4_Setup 作为安装类。这是通过添加之前在 app/code/core/Mage/Sales/etc/config.xml 中找到的相同 xml 元素来完成的(将 sales_setup 替换为 yourmod_setup)。因此,您转储数据库,通过在 mysql4-install-0.1.0.php 文件中使用 get_class($this) 检查它是否正常工作,然后恢复数据库。然后,您继续编写设置文件,从 app/code/core/Mage/Sales/sql/sales_setup 中的文件中看到的内容中汲取灵感,应该没问题!
现在第二点...我不知道...我希望它会自动起作用!
祝你好运!

Disclaimer: I have not touched Magento for 6 months.
Now this is said, if you look in the app/code/core/Mage/Sales/sql/sales_setup/ directory you will find examples of how to modify order tables. For instance here is the content of app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.12-0.9.13.php (without header comments):

$installer = $this;
/* @var $installer Mage_Sales_Model_Mysql4_Setup */

$installer->addAttribute('quote', 'subtotal', array('type'=>'decimal'));
$installer->addAttribute('quote', 'base_subtotal', array('type'=>'decimal'));

$installer->addAttribute('quote', 'subtotal_with_discount', array('type'=>'decimal'));
$installer->addAttribute('quote', 'base_subtotal_with_discount', array('type'=>'decimal'));

$this is initialized from what is found in the app/code/core/Mage/Sales/etc/config.xml following the config/global/resources/sales_setup/setup/class look into this class and you'll see it inherits from Mage_Eav_Model_Entity_Setup, the default setup class, and overrides or add some methods (for flat table support for instance).

To answer your first point (first question), you can add columns by using the addAttribute() method of this class. And the answer to the second question is yes, but you have to specify in the config.xml file of your module that you want to use Mage_Sales_Model_Mysql4_Setup as setup class. This is done by adding the same xml element found in app/code/core/Mage/Sales/etc/config.xml previously (replace sales_setup with yourmod_setup). So you dump your database, you check it works by using get_class($this) in your mysql4-install-0.1.0.php file, and then you restore your db. And you continue writing in your setup file, inspiring yourself from what you see in the files in app/code/core/Mage/Sales/sql/sales_setup and it should be fine!
Now for the second point... I don't know... I hope it'll work automatically!
Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文