【问题标题】:向 Category Bundle Orocommerce 添加新字段
【发布时间】:2022-01-23 16:12:03
【问题描述】:

我正在尝试将 ManyToManyRelation 添加到类别实体,但是当我清除缓存时出现该字段不存在的错误。

 public function up(Schema $schema, QueryBag $queries)
    {
        $this->createNewGammeTable($schema);
        $this->extendExtension->addManyToManyRelation(
            $schema,
            self::CATEGORY_TABLE_NAME,
            "new_ranges",
            self::NEW_GAMME_TABLE_NAME,
            ["gamme_id"],
            ["gamme_id"],
            ["gamme_id"],
            [
                "extend" => ["owner" => ExtendScope::OWNER_CUSTOM, 'cascade' => ['all']],
                'form' => [
                    'form_type' => NewGammeCollectionType::class
                ]
            ]
        );
    }
    protected function createNewGammeTable(Schema $schema)
    {
        $table = $schema->createTable(self::NEW_GAMME_TABLE_NAME);
        $table->addColumn("id", "integer", ["autoincrement" => true]);
        $table->addColumn("gamme_id", "integer", ["notnull" => false]);
        $table->addColumn("sort_order", "integer");
        $table->setPrimaryKey(["id"]);
    }

所以当我清除缓存时,我得到:

In RuntimeReflectionService.php line 76:
                                                                               
  Property Oro\Bundle\CatalogBundle\Entity\Category::$new_ranges does not exi  
  st 

在开发环境中我没有收到此错误。但是在 orocommerce 平台中,当我尝试编辑我得到的类别时

An exception occurred while executing 'SELECT t0.id AS id_1, t0.sort_order AS sort_order_2, t0.gamme_id AS gamme_id_3 FROM gdm_new_gamme t0 INNER JOIN oro_rel_ff3a7b9752519dfcec0789 ON t0.id = oro_rel_ff3a7b9752519dfcec0789.newgamme_id WHERE oro_rel_ff3a7b9752519dfcec0789.category_id = ?' with params [2]:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'oro_db.oro_rel_ff3a7b9752519dfcec0789' doesn't exist

【问题讨论】:

  • 您的new_ranges 表/类中有new_ranges 属性吗?
  • 不,我不这样做,$this->extendExtension->addManyToManyRelation() 不应该添加它吗?

标签: symfony orocrm orocommerce


【解决方案1】:

我通过使用oro:entity-extend:cache:clear 更新我的实体解决了我的问题 和oro:entity-extend:update-schema

【讨论】:

    猜你喜欢
    • 2021-07-10
    • 1970-01-01
    • 2021-05-28
    • 2020-07-01
    • 2019-07-19
    • 1970-01-01
    • 2012-10-27
    • 2017-04-21
    • 1970-01-01
    相关资源
    最近更新 更多