I have a Magento website configured with 1 website and 2 stores. Each store products are separated with root category, means each store has their own root category.

I want the products from store A not searchable from store B. How to override search to do such thing? which method should I look into?

Note: I don't want to use Visibility setting due to some reasons such as it will make a product from another store not clickable in cart/mini cart.

3 Answers 3


unassign products of Store A that you don't want to be shown in Store B, and they won't be searchable. ( Websites Tab in Product Edit mode)

  • how to "unassign" them in particural store? i have products assigned to root category for store B searchable from store A that has another root category. Oct 16, 2014 at 4:58
  • in backend Catalog->Manage Products-> Edit a product Websites Tab, uncheck the site you don't want that product to appear in. Oct 16, 2014 at 5:44
  • it's multi store, not multi website. Multi website will make it harder to manage the session (login, cart, etc) between websites. and our site shares the cart and login session between stores. Oct 16, 2014 at 6:50

To override the search you should rewrite the ResultController from catalogsearch module in magento core. It would be nice to override helper also.

  • already looked into it and i need to put addAttributeToFilter on the collection. where should i put it? Oct 14, 2014 at 9:38

I put addAttributeToFilter by rewriting Mage_CatalogSearch_Model_Layer::getProductCollection()


<?xml version="1.0"?>

Then in my app/code/local/Vela/CatalogSearch/Model/Layer.php file


class Vela_CatalogSearch_Model_Layer extends Mage_CatalogSearch_Model_Layer
public function getProductCollection()
  if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
      $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
  } else {
      $collection = Mage::getResourceModel('catalogsearch/fulltext_collection');
      $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;

  // start modification
  $store_id = Mage::app()->getStore()->getId();
  $store_code =  Mage::app()->getStore()->getCode();

  $_product = Mage::getModel('catalog/product');
  $_attr = $_product->getResource()->getAttribute('universo_store');
  if ($_attr->usesSource()) {
      $_attr_option_id_seafolly = $_attr->getSource()->getOptionId("seafolly");
      $_attr_option_id_havaianas = $_attr->getSource()->getOptionId("seafolly");

  if(stripos('seafolly',$store_code) !== FALSE){ // seafolly
      $store_id = $_attr_option_id_seafolly;
  } else {//havaianas
      $store_id = $_attr_option_id_havaianas;

  $collection->addAttributeToFilter('universo_store', array('eq'=>$store_id));
  // end modification

  return $collection;
  • i will, i am waiting for the timer to go off Oct 16, 2014 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.