Magento: store-specific software search

I am using the Magento catalog search module. I have 2 stores. When searching for a “test” on the first, I get 5 results. When searching for a “test” on the second, I get 3 results.

I would like to add the results of the second store (only the number of results) when I search in the first.

I added a block and a template, all I need is code to extract the number of results in the second repository and where I got stuck.

I tried to get the controller code, but it always returns me the number of results in the first repository:

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;

      }

, : Mage:: () → setCurrentStore ($ secondStoreId);

?

+3
1

, , , , Mage_Catalogsearch_Model_Query. . , $collection, .

$queryText = Mage::helper('catalogSearch')->getQueryText();
$collection = Mage::getResourceModel('catalogsearch/query_collection')
    ->setStoreId($storeId)
    ->setQueryFilter($queryText);
+1

Source: https://habr.com/ru/post/1768395/


All Articles