【问题标题】:Magento 2 set-dimensions-mode gives errorMagento 2 set-dimensions-mode 给出错误
【发布时间】:2023-01-11 22:36:18
【问题描述】:

我正在尝试在并行模式下重新编制索引,并且正在尝试根据文档更改维度模式

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,

知道我该如何解决这个问题。

【问题讨论】:

    标签: magento2 reindex


    【解决方案1】:

    当您通过 CLI 更改维度模式时,Magento 应该创建所需的表(请参阅MagentoCatalogModelIndexerProductPrice::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 [];
        }
    }
    

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

    【讨论】:

    • 该错误表明它正在寻找客户群和网站,所以我不确定您之前是否尝试过将其设置为该网站。可能值得尝试 bin/magento indexer:set-dimensions-mode website_and_customer_group 然后 bin/magento indexer:set-dimensions-mode catalog_product_price website
    猜你喜欢
    • 2019-02-06
    • 2016-10-18
    • 2021-07-06
    • 2016-04-26
    • 2023-03-16
    • 2022-06-30
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多