private function addProductData($data)
    {
        $product = $data['product'];

        $productData = [
            'title' => $product->getName(),
            'image' => $this->getImageUrl($product),
            'url'   => $product->getProductUrl(),
            'price' => $this->renderProductPrice($product, \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE),
        ];

        foreach ($this->attributes as $attributeCode) {
            if ($product->hasData($attributeCode)) {
                $productData[$attributeCode] = $product->getData($attributeCode);
                if ($product->getResource()->getAttribute($attributeCode)->usesSource()) {
                    $productData[$attributeCode] = $product->getAttributeText($attributeCode);
                }
            }
        }

        $data = array_merge($data, $productData);

        return $data;
    }
private function addProductData($data)
    {
        $product = $data['product'];

        $productData = [
            'title' => $product->getName(),
            'image' => $this->getImageUrl($product),
            'url'   => $product->getProductUrl(),
            'price' => $this->renderProductPrice($product, \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE),
        ];

        foreach ($this->attributes as $attributeCode) {
            if ($product->hasData($attributeCode)) {
                $productData[$attributeCode] = $product->getData($attributeCode);
                if ($product->getResource()->getAttribute($attributeCode)->usesSource()) {
                    $productData[$attributeCode] = $product->getAttributeText($attributeCode);
                }
            }
        }

        $data = array_merge($data, $productData);

        return $data;
    }
private function addProductData ( $ data ) { $ product = $ data [ 'product' ] ; $ productData = [ 'title' => $ product -> getName ( ) , 'image' => $ this -> getImageUrl ( $ product ) , 'url' => $ product -> getProductUrl ( ) , 'price' => $ this -> renderProductPrice ( $ product , \ Magento \ Catalog \ Pricing \ Price \ FinalPrice :: PRICE_CODE ) , ] ; foreach ( $ this -> attributes as $ attributeCode ) { if ( $ product -> hasData ( $ attributeCode ) ) { $ productData [ $ attributeCode ] = $ product -> getData ( $ attributeCode ) ; if ( $ product -> getResource ( ) -> getAttribute ( $ attributeCode ) -> usesSource ( ) ) { $ productData [ $ attributeCode ] = $ product -> getAttributeText ( $ attributeCode ) ; } } } $ data = array_merge ( $ data , $ productData ) ; return $ data ; }
Load product data and append them to the original data.

@param array $data Autocomplete item data.

@return array
Load product data and append them to the original data .