【问题标题】:Magento 2 add custom column into quote tableMagento 2 将自定义列添加到报价表中
【发布时间】:2020-03-20 00:49:48
【问题描述】:

我正在尝试在 Magento 2 的报价表中添加另一列。

应用程序/代码/[公司名称]/[模块]/Setup/UpgradeSchema.php

这是我的代码:

use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Quote\Setup\QuoteSetupFactory;
use Magento\Framework\DB\Ddl\Table;
use Magento\Quote\Setup\QuoteSetup;


class UpgradeSchema implements UpgradeSchemaInterface
{
    public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();
        $connection = $installer->getConnection();
        $connection->addColumn($installer->getTable('quote'), 'can_ship_partially', [
            'type'     => Table::TYPE_SMALLINT,
            'nullable' => true,
            'comment'  => 'Custom can ship partial'
        ]);

        $installer->endSetup();
    }

}//End of class

但是当我运行sudo php bin/magento setup:upgrade 时,can_ship_partially 列从未出现在报价表中。有人可以告诉我我做错了什么吗?谢谢

【问题讨论】:

    标签: magento2


    【解决方案1】:

    您的代码运行良好,所以我认为您的 Schema-Script 永远不会被调用。 增加模块设置版本时调用模式脚本。 检查您的数据库,表“module_module”并搜索您的模块条目。将 version 值与 module.xml 中的 setup_version 值进行比较。如果值相同,请尝试增加 module.xml 中的 setup_version。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多