Laizer
Laizer

Reputation: 6140

Embedding search results (or tagged products) in a Magento CMS page

I can embed a block in a CMS page without difficulty. I can also pass arguments to the block without difficulty.

What I'm looking to do is embed a block in a CMS page that returns search results for a particular search phrase.

Embedding all products with a particular tag would also be helpful.

Neither one has been easy to do.

Upvotes: 1

Views: 868

Answers (1)

user1876292
user1876292

Reputation: 31

I was looking for the same and here is my find so far..

$search = Mage::getSingleton('catalogsearch/advanced')->addFilters(array('name' => $term));
$prodCollection = $search->getProductCollection();

Then you can go through the Collection -

<?php
$i=1;  // To display number of items in the page (Here we restricted upto 4)
foreach($prdIds as $_prdIds){ // Fetching out the products
$prodId = $_prdIds;
$obj = Mage::getModel(‘catalog/product’);
$_product = $obj->load($prodId);
...
?>

Hope it helps someone though..

Upvotes: 3

Related Questions