How can I echo the SKU list of the items in the search results page, but in the header of Magento? Currently using M1. I'm using the code below to echo the list of SKUs of a specific category page to the header, but I don't know how to get the list of SKUs in the search results page.
if (Mage::registry('current_category'))
{
$category_id = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
$category = Mage::getModel('catalog/category')->load($category_id);
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addCategoryFilter($category)
->setOrder('price', 'ASC')
->load();
$skuArray = array();
foreach ($products as $item) {
$skuArray[] = "\"" . $item->getSku() . "\"";
}
echo Mage::registry('current_category')->getID();
echo implode( ', ', $skuArray);
I tried the solution in this link, but it doesn't seem to work: How to get Search result Product collection outside result.phtml
Any suggestion would be greatly appreciated. :D