Magento 2设定二级模式给出错误

发布于 2025-01-20 19:41:37 字数 613 浏览 1 评论 0原文

我正在尝试在并行模式下重新索引,并且正在尝试根据文档

https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-index.html#reindexing-in-parallel-mode

我得到了这个错误

bin/magento indexer:set-dimensions-mode catalog_product_price website

"Product Price" indexer process unknown error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 
'db.catalog_product_index_price_cg0_ws1' doesn't exist,

知道如何解决这个问题。

Iam trying to do reindexing-in-parallel-mode and I am trying to change the dimensions mode according to the document

https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-index.html#reindexing-in-parallel-mode

I am getting this error

bin/magento indexer:set-dimensions-mode catalog_product_price website

"Product Price" indexer process unknown error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 
'db.catalog_product_index_price_cg0_ws1' doesn't exist,

Any idea how can i fix this.

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

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

发布评论

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

评论(1

红玫瑰 2025-01-27 19:41:37

当您通过 CLI 更改维度模式时,Magento 应该创建所需的表(请参阅 Magento\Catalog\Model\Indexer\Product\Price::createTables($currentMode)

)失败,或者更可能的是您以其他方式切换了维度模式,例如通过数据补丁,该方法永远不会被调用,导致我们在这里看到的错误。

为了解决这个问题,我们可以通过数据补丁自己调用这个方法:

Class CreateDimensionsTables implements DataPatchInterface
{
    private ModeSwitcher $modeSwitcher;

    public function __construct(ModeSwitcher $modeSwitcher)
    {
        $this->modeSwitcher = $modeSwitcher;
    }

    public function apply()
    {
        $this->modeSwitcher->createTables(DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP);
    }

    public static function getDependencies()
    {
       return [SetPriceIndexerDimensionsMode::class];
    }

    public function getAliases()
    {
        return [];
    }
}

这应该创建任何需要的表,并且索引器应该能够成功运行。

When you change the dimensions mode via the CLI, Magento should create the needed tables (See Magento\Catalog\Model\Indexer\Product\Price::createTables($currentMode))

If however, this particular part fails, or more likely you've switched the dimensions mode some other way, e.g. via a datapatch, this method is never called, leading to the errors we see here.

To get around this, we can just call this method ourselves via a datapatch:

Class CreateDimensionsTables implements DataPatchInterface
{
    private ModeSwitcher $modeSwitcher;

    public function __construct(ModeSwitcher $modeSwitcher)
    {
        $this->modeSwitcher = $modeSwitcher;
    }

    public function apply()
    {
        $this->modeSwitcher->createTables(DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP);
    }

    public static function getDependencies()
    {
       return [SetPriceIndexerDimensionsMode::class];
    }

    public function getAliases()
    {
        return [];
    }
}

This should create any needed tables and the indexer should be able to run successfully.

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