php - Magento: programmatic search depending on store -


i'm using catalogsearch module of magento. have 2 stores. when searching "test" on first one, 5 results. when searching "test" on second one, 3 results.

i'd add results of second store (just number of results) when search in first one.

i added block , template, need code retrieve number of results in second store, , that's i'm stucked.

i tried controller code, returns me number of results in first store :

private function _getstorequery($storeid) {

          $query = mage::helper('catalogsearch')->getquery();     $query->setstoreid(7);              if ($query->getquerytext()) {         if (mage::helper('catalogsearch')->isminquerylength()) 

{ $query->setid(0) ->setisactive(1) ->setisprocessed(1); } else { if ($query->getid()) { $query->setpopularity($query->getpopularity()+1); } else { $query->setpopularity(1); }

            $query->prepare();         }          mage::helper('catalogsearch')->checknotes();          if (!mage::helper('catalogsearch')->isminquerylength()) 

{ $query->save(); } }

    var_dump($query);     return $query;        } 

i tried change store context before, no luck: mage::app()->setcurrentstore($secondstoreid);

do have idea? thanks

probably reason first set of results returned on second try because reusing mage_catalogsearch_model_query object. need create new set of results instead. here collection create those, need iterate through $collection them.

$querytext = mage::helper('catalogsearch')->getquerytext(); $collection = mage::getresourcemodel('catalogsearch/query_collection')     ->setstoreid($storeid)     ->setqueryfilter($querytext); 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -