In this function-
public function getResults()
{
$results = [];
foreach ($this->getLoadedProductCollection() as $product) {
$data['img'] = $this->encodeMediaUrl(
$this->getImage($product, 'amasty_xsearch_page_list')-
>toHtml()
);
$data['url'] = $product->getProductUrl();
$data['name'] = $this->getName($product);
$data['description'] = $this->getDescription($product);
$data['sku'] = $this->getSku($product);
$data['price'] = $this->getProductPrice($product);
$data['is_salable'] = $product->isSaleable();
$data['product_data'] = [
'entity_id' => (string)$product->getId(),
'request_path' => (string)$product->getRequestPath()
];
$data['reviews'] = $this->getReviewsSummaryHtml($product,
ReviewRendererInterface::SHORT_VIEW);
$results[$product->getId()] = $data;
}
$this->setNumResults($this->getLoadedProductCollection()-
>getSize());
return $results;
}
I added this line-
$data['sku'] = $this->getSku($product);
I then created this function-
public function getSku(\Magento\Catalog\Model\Product $product)
{
return $this->getResults()->get($sku);
}
On the page I am trying to display it on I have this code-
<?= $product['sku'] ?>
The extension pulls the name and description so I tried to just copy what was done for those attributes but it doesn't seem to work.
$sku
variablepublic function getSku($sku) { return $this->getResults()->get($sku); }