public function getData()
    {
        $baseResults  = $this->getBaseResults();
        $baseProducts = $this->preparePreviewItems($baseResults);

        $optimizedResults  = $this->canApply() ? $this->getOptimizedResults() : $baseResults;
        $optimizedProducts = $this->preparePreviewItems($optimizedResults);

        $effectFunction = function ($document) use ($baseProducts, $optimizedProducts) {
            $document['effect'] = $this->getEffectOnProduct(
                array_keys($baseProducts),
                array_keys($optimizedProducts),
                $document['id']
            );

            return $document;
        };

        $optimizedProducts = array_map($effectFunction, $optimizedProducts);

        $data = [
            'base_products'      => array_values($baseProducts),
            'optimized_products' => array_values($optimizedProducts),
            'size'               => max($baseResults->count(), $optimizedResults->count()), // Should be the same.
        ];

        return $data;
    }
public function getData()
    {
        $baseResults  = $this->getBaseResults();
        $baseProducts = $this->preparePreviewItems($baseResults);

        $optimizedResults  = $this->canApply() ? $this->getOptimizedResults() : $baseResults;
        $optimizedProducts = $this->preparePreviewItems($optimizedResults);

        $effectFunction = function ($document) use ($baseProducts, $optimizedProducts) {
            $document['effect'] = $this->getEffectOnProduct(
                array_keys($baseProducts),
                array_keys($optimizedProducts),
                $document['id']
            );

            return $document;
        };

        $optimizedProducts = array_map($effectFunction, $optimizedProducts);

        $data = [
            'base_products'      => array_values($baseProducts),
            'optimized_products' => array_values($optimizedProducts),
            'size'               => max($baseResults->count(), $optimizedResults->count()), // Should be the same.
        ];

        return $data;
    }
public function getData ( ) { $ baseResults = $ this -> getBaseResults ( ) ; $ baseProducts = $ this -> preparePreviewItems ( $ baseResults ) ; $ optimizedResults = $ this -> canApply ( ) ? $ this -> getOptimizedResults ( ) : $ baseResults ; $ optimizedProducts = $ this -> preparePreviewItems ( $ optimizedResults ) ; $ effectFunction = function ( $ document ) use ( $ baseProducts , $ optimizedProducts ) { $ document [ 'effect' ] = $ this -> getEffectOnProduct ( array_keys ( $ baseProducts ) , array_keys ( $ optimizedProducts ) , $ document [ 'id' ] ) ; return $ document ; } ; $ optimizedProducts = array_map ( $ effectFunction , $ optimizedProducts ) ; $ data = [ 'base_products' => array_values ( $ baseProducts ) , 'optimized_products' => array_values ( $ optimizedProducts ) , 'size' => max ( $ baseResults -> count ( ) , $ optimizedResults -> count ( ) ) , // Should be the same. ] ; return $ data ; }
Load preview data.

@return array
Load preview data .