2

I noticed something when looking over the source code and noticed that the catalog search indexer can fire for a specific store by accepting a $storeId parameter. app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php

  /**
     * Regenerate search index for specific store
     *
     * @param int $storeId Store View Id
     * @param int|array $productIds Product Entity Id
     * @return Mage_CatalogSearch_Model_Resource_Fulltext
     */
    protected function _rebuildStoreIndex($storeId, $productIds = null)

Has anyone needed to specifically target the search indexer for a specific store? If so it doesn't look like Magento provides a decent way of calling this method as the rebuildIndex function itself just loops through the stores and calls it.

public function rebuildIndex($storeId = null, $productIds = null)
{
    if (is_null($storeId)) {
        $storeIds = array_keys(Mage::app()->getStores());
        foreach ($storeIds as $storeId) {
            $this->_rebuildStoreIndex($storeId, $productIds);
        }
    } else {
        $this->_rebuildStoreIndex($storeId, $productIds);
    }

    return $this;
}

Might be a neat n98-magerun feature. n98-magerun.phar index:reindex catalogsearch_fulltext $store_id

1
  • Actually rebuildIndex only loops through stores if $storeId is not provided. So you can call public rebuildIndex for specific store.
    – Anton Kril
    Commented Nov 8, 2014 at 10:33

1 Answer 1

1

As Anton said, you can just provide a store_id to the function. This works, I haven't felt the need myself yet as we tend to switch to Solr for bigger environments.

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.