src/searchOld/elastic/Watch.php
private static function prepareEav($model, $props, $index, $type, $languages)
    {
        $eavTable = $model->eavTable();
        $values = (new Query())
            ->from($eavTable)
            ->where([
                'model_id' => $model->id,
                'property_id' => array_keys($props)
            ])
            ->select([
                'id',
                'property_id',
                'value_integer',
                'value_float',
                'value_string',
                'value_text',
                'language_id'
            ])
            ->all();
        $rows = $data = [];
        foreach ($values as $val) {
            $propKey = isset($props[$val['property_id']]) ? $props[$val['property_id']] : null;
            $row = [
                'eav_value_id' => $val['id'],
                'prop_id' => $val['property_id'],
                'prop_key' => $propKey,
                'value_integer' => $val['value_integer'],
                'value_float' => $val['value_float'],
            ];
            if ($val['language_id'] == 0) {
                $row['utr_text'] = $val['value_text'];
            } else {
                if (false === isset($languages[$val['language_id']])) {
                    continue;
                }
                $row['str_value_' . $languages[$val['language_id']]] = $val['value_string'];
                $row['txt_value_' . $languages[$val['language_id']]] = $val['value_text'];
            }
            $rows[] = $row;
        }
        if (false === empty($rows)) {
            $data['body'][] = ['index' => [
                '_id' => $model->id,
                '_index' => $index,
                '_type' => $type,
            ]];
            $data['body'][] = [
                'model_id' => $model->id,
                Search::EAV_FIELD => $rows,
            ];
        }
        return $data;
    }
private static function prepareEav($model, $props, $index, $type, $languages)
    {
        $eavTable = $model->eavTable();
        $values = (new Query())
            ->from($eavTable)
            ->where([
                'model_id' => $model->id,
                'property_id' => array_keys($props)
            ])
            ->select([
                'id',
                'property_id',
                'value_integer',
                'value_float',
                'value_string',
                'value_text',
                'language_id'
            ])
            ->all();
        $rows = $data = [];
        foreach ($values as $val) {
            $propKey = isset($props[$val['property_id']]) ? $props[$val['property_id']] : null;
            $row = [
                'eav_value_id' => $val['id'],
                'prop_id' => $val['property_id'],
                'prop_key' => $propKey,
                'value_integer' => $val['value_integer'],
                'value_float' => $val['value_float'],
            ];
            if ($val['language_id'] == 0) {
                $row['utr_text'] = $val['value_text'];
            } else {
                if (false === isset($languages[$val['language_id']])) {
                    continue;
                }
                $row['str_value_' . $languages[$val['language_id']]] = $val['value_string'];
                $row['txt_value_' . $languages[$val['language_id']]] = $val['value_text'];
            }
            $rows[] = $row;
        }
        if (false === empty($rows)) {
            $data['body'][] = ['index' => [
                '_id' => $model->id,
                '_index' => $index,
                '_type' => $type,
            ]];
            $data['body'][] = [
                'model_id' => $model->id,
                Search::EAV_FIELD => $rows,
            ];
        }
        return $data;
    }
private static function prepareEav ( $ model , $ props , $ index , $ type , $ languages ) { $ eavTable = $ model -> eavTable ( ) ; $ values = ( new Query ( ) ) -> from ( $ eavTable ) -> where ( [ 'model_id' => $ model -> id , 'property_id' => array_keys ( $ props ) ] ) -> select ( [ 'id' , 'property_id' , 'value_integer' , 'value_float' , 'value_string' , 'value_text' , 'language_id' ] ) -> all ( ) ; $ rows = $ data = [ ] ; foreach ( $ values as $ val ) { $ propKey = isset ( $ props [ $ val [ 'property_id' ] ] ) ? $ props [ $ val [ 'property_id' ] ] : null ; $ row = [ 'eav_value_id' => $ val [ 'id' ] , 'prop_id' => $ val [ 'property_id' ] , 'prop_key' => $ propKey , 'value_integer' => $ val [ 'value_integer' ] , 'value_float' => $ val [ 'value_float' ] , ] ; if ( $ val [ 'language_id' ] == 0 ) { $ row [ 'utr_text' ] = $ val [ 'value_text' ] ; } else { if ( false === isset ( $ languages [ $ val [ 'language_id' ] ] ) ) { continue ; } $ row [ 'str_value_' . $ languages [ $ val [ 'language_id' ] ] ] = $ val [ 'value_string' ] ; $ row [ 'txt_value_' . $ languages [ $ val [ 'language_id' ] ] ] = $ val [ 'value_text' ] ; } $ rows [ ] = $ row ; } if ( false === empty ( $ rows ) ) { $ data [ 'body' ] [ ] = [ 'index' => [ '_id' => $ model -> id , '_index' => $ index , '_type' => $ type , ] ] ; $ data [ 'body' ] [ ] = [ 'model_id' => $ model -> id , Search :: EAV_FIELD => $ rows , ] ; } return $ data ; }
Prepares bulk data to store in elasticsearch index for model properties eav values

@param HasProperties | PropertiesTrait $model
@param array $props
@param string $index
@param string $type
@param array $languages
@return array
Prepares bulk data to store in elasticsearch index for model properties eav values