protected function truncateFields(Collection $collection, array &$generatedRow)
    {
        // Find the name of any indexed fields
        $indexedFields = [];
        $indexesGroupedByCollection = $this->config->getIndexesGroupedByCollection($this->storeName);
        if (isset($indexesGroupedByCollection) && isset($indexesGroupedByCollection[$collection->getCollectionName()]))
        {
            $indexes = $indexesGroupedByCollection[$collection->getCollectionName()];
            if (isset($indexes))
            {
                foreach($indexes as $repset)
                {
                    foreach ($repset as $index)
                    {
                        foreach ($index as $indexedFieldname => $v)
                        {
                            if (strpos($indexedFieldname, "value.") === 0)
                            {
                                $indexedFields[] = substr($indexedFieldname, strlen('value.'));
                            }
                        }
                    }
                }
            }
        }

        if (count($indexedFields) > 0 && isset($generatedRow['value']) && is_array($generatedRow['value']))
        {
            // Iterate over generated rows BY REFERENCE (&) - we are going to modify the contents of $field
            foreach($generatedRow as &$field)
            {
                foreach($indexedFields as $indexedFieldname)
                {
                    // The key will have the index name in the following format added to it.
                    // Adjust the max key size allowed to take it into account.
                    $maxKeySize = 1020 - strlen("value_".$indexedFieldname."_1");

                    if (array_key_exists($indexedFieldname, $field))
                    {
                        // It's important that we count the number of bytes
                        // in the field - not just the number of characters.
                        // UTF-8 characters can be between 1 and 4 bytes.
                        //
                        // From the strlen documentation:
                        //     Attention with utf8:
                        //     $foo = "bär";
                        //     strlen($foo) will return 4 and not 3 as expected..
                        //
                        // So strlen does count the bytes - not the characters.

                        if (is_string($field[$indexedFieldname]) && strlen($field[$indexedFieldname]) > $maxKeySize)
                        {
                            $field[$indexedFieldname] = substr($field[$indexedFieldname],0, $maxKeySize);
                        }
                    }
                }
            }
        }
    }
protected function truncateFields(Collection $collection, array &$generatedRow)
    {
        // Find the name of any indexed fields
        $indexedFields = [];
        $indexesGroupedByCollection = $this->config->getIndexesGroupedByCollection($this->storeName);
        if (isset($indexesGroupedByCollection) && isset($indexesGroupedByCollection[$collection->getCollectionName()]))
        {
            $indexes = $indexesGroupedByCollection[$collection->getCollectionName()];
            if (isset($indexes))
            {
                foreach($indexes as $repset)
                {
                    foreach ($repset as $index)
                    {
                        foreach ($index as $indexedFieldname => $v)
                        {
                            if (strpos($indexedFieldname, "value.") === 0)
                            {
                                $indexedFields[] = substr($indexedFieldname, strlen('value.'));
                            }
                        }
                    }
                }
            }
        }

        if (count($indexedFields) > 0 && isset($generatedRow['value']) && is_array($generatedRow['value']))
        {
            // Iterate over generated rows BY REFERENCE (&) - we are going to modify the contents of $field
            foreach($generatedRow as &$field)
            {
                foreach($indexedFields as $indexedFieldname)
                {
                    // The key will have the index name in the following format added to it.
                    // Adjust the max key size allowed to take it into account.
                    $maxKeySize = 1020 - strlen("value_".$indexedFieldname."_1");

                    if (array_key_exists($indexedFieldname, $field))
                    {
                        // It's important that we count the number of bytes
                        // in the field - not just the number of characters.
                        // UTF-8 characters can be between 1 and 4 bytes.
                        //
                        // From the strlen documentation:
                        //     Attention with utf8:
                        //     $foo = "bär";
                        //     strlen($foo) will return 4 and not 3 as expected..
                        //
                        // So strlen does count the bytes - not the characters.

                        if (is_string($field[$indexedFieldname]) && strlen($field[$indexedFieldname]) > $maxKeySize)
                        {
                            $field[$indexedFieldname] = substr($field[$indexedFieldname],0, $maxKeySize);
                        }
                    }
                }
            }
        }
    }
protected function truncateFields ( Collection $ collection , array & $ generatedRow ) { // Find the name of any indexed fields $ indexedFields = [ ] ; $ indexesGroupedByCollection = $ this -> config -> getIndexesGroupedByCollection ( $ this -> storeName ) ; if ( isset ( $ indexesGroupedByCollection ) && isset ( $ indexesGroupedByCollection [ $ collection -> getCollectionName ( ) ] ) ) { $ indexes = $ indexesGroupedByCollection [ $ collection -> getCollectionName ( ) ] ; if ( isset ( $ indexes ) ) { foreach ( $ indexes as $ repset ) { foreach ( $ repset as $ index ) { foreach ( $ index as $ indexedFieldname => $ v ) { if ( strpos ( $ indexedFieldname , "value." ) === 0 ) { $ indexedFields [ ] = substr ( $ indexedFieldname , strlen ( 'value.' ) ) ; } } } } } } if ( count ( $ indexedFields ) > 0 && isset ( $ generatedRow [ 'value' ] ) && is_array ( $ generatedRow [ 'value' ] ) ) { // Iterate over generated rows BY REFERENCE (&) - we are going to modify the contents of $field foreach ( $ generatedRow as & $ field ) { foreach ( $ indexedFields as $ indexedFieldname ) { // The key will have the index name in the following format added to it. // Adjust the max key size allowed to take it into account. $ maxKeySize = 1020 - strlen ( "value_" . $ indexedFieldname . "_1" ) ; if ( array_key_exists ( $ indexedFieldname , $ field ) ) { // It's important that we count the number of bytes // in the field - not just the number of characters. // UTF-8 characters can be between 1 and 4 bytes. // // From the strlen documentation: //     Attention with utf8: //     $foo = "bär"; //     strlen($foo) will return 4 and not 3 as expected.. // // So strlen does count the bytes - not the characters. if ( is_string ( $ field [ $ indexedFieldname ] ) && strlen ( $ field [ $ indexedFieldname ] ) > $ maxKeySize ) { $ field [ $ indexedFieldname ] = substr ( $ field [ $ indexedFieldname ] , 0 , $ maxKeySize ) ; } } } } } }
Truncate any indexed fields in the generated rows which are too large to index

@param Collection $collection
@param array $generatedRow - Pass by reference so that the contents is truncated
Truncate any indexed fields in the generated rows which are too large to index