0

Magento インストールの属性の量が原因で、MySQL の行制限に問題があったため、次のコードを使用して 'Mage_Catalog_Model_Resource_Product_Flat_Indexer' クラスを拡張し、文字制限を 64 に書き換える拡張機能をまとめました。

protected function _MySQLCharLimit()
{
    if (!$this->_isFlatTableExists($store)) {

        $sql = "CREATE TABLE {$tableNameQuote} (n";

        foreach ( $columns as $field => $fieldProp ) {
            if ( $fieldProp['type'] == "varchar(255)" )
            $fieldProp['type'] = "varchar(64)";
                $sql .= sprintf( "  %s,n",
                $this->_sqlColunmDefinition( $field, $fieldProp ) );
        }
        foreach ($addIndexes as $indexName => $indexProp) {
            $sql .= sprintf(' ADD %s,',
            $this->_sqlIndexDefinition( $indexName, $indexProp ) );
        }
        $sql = rtrim($sql, ",");
        $sql = str_replace( "varchar(255)","varchar(64)",$sql );
        $this->_getWriteAdapter()->query( $sql );
    }
}

ここから入手したhttp://www.sonassi.com/knowledge-base/magento-kb/mysql-limitations-on-the-flat-catalogue-in-magento/

インデックスを再作成しようとした後、空白のページが表示され、クリックして戻ると「Product Flat Data」インデックスが処理中にスタックしていることに気付きました。

SSH 経由で「shell」フォルダーから indexer.php を実行したところ、次のエラーが報告されました。

PHP の致命的なエラー: 296 行目の Mage/Catalog/Model/Product/Flat/Indexer.php の非オブジェクトに対するメンバー関数 reindexAll() の呼び出し

何がうまくいかなかったか、またはこれをどのように修正できるかについて、誰かが何か考えを持っていますか? ありがとう。

編集:完全なコード

<?php
class GDModules_MySQLCharLimit_Catalog_Model_Resource_Product_Flat_Indexer extends Mage_Catalog_Model_Resource_Product_Flat_Indexer
{
    public function mySQLCharLimit()
    {
        if (!$this->_isFlatTableExists($store)) {

            $sql = "CREATE TABLE {$tableNameQuote} (n";

            foreach ( $columns as $field => $fieldProp ) {
                if ( $fieldProp['type'] == "varchar(255)" )
                $fieldProp['type'] = "varchar(64)";
                    $sql .= sprintf( "  %s,n",
                    $this->_sqlColunmDefinition( $field, $fieldProp ) );
            }
            foreach ($addIndexes as $indexName => $indexProp) {
                $sql .= sprintf(' ADD %s,',
                $this->_sqlIndexDefinition( $indexName, $indexProp ) );
            }
            $sql = rtrim($sql, ",");
            $sql = str_replace( "varchar(255)","varchar(64)",$sql );
            $this->_getWriteAdapter()->query( $sql );
        }
    }
}

XML

<?xml version="1.0" encoding="UTF-8"?>

<!-- The root node for Magento module configuration -->
<config>

    <!--
    The module's node contains basic
    information about each Magento module
    -->
    <modules>

        <!--
        This must exactly match the namespace and module's folder
        names, with directory separators replaced by underscores
        -->
        <GDModules_MySQLCharLimit>

            <!-- The version of our module, starting at 0.0.1 -->
            <version>0.0.1</version>
        </GDModules_MySQLCharLimit>
    </modules>

    <!-- Configure our module's behaviour in the global scope -->
    <global>
        <!-- Defining models -->
        <models>
            <catalog_resource>
                <rewrite>
                    <product_flat_indexer>GDModules_MySQLCharLimit_Catalog_Model_Resource_Product_Flat_Indexer</product_flat_indexer>
                </rewrite>
            </catalog_resource>
        </models>
    </global>
</config>
4

0 に答える 0