studioespresso / craft-scout

Craft Scout provides a simple solution for adding full-text search to your entries. Scout will automatically keep your search indexes in sync with your entries.
MIT License
81 stars 54 forks source link

Commerce product indexing multi-site #157

Open epapada opened 4 years ago

epapada commented 4 years ago

We have an index for each site. We loop through each site and create the index like so:

foreach (Craft::$app->getSites()->getAllSites() as $site) {
    $algoliaIndices['products'.$site->id] =
        \rias\scout\ScoutIndex::create(getenv('ENVIRONMENT').'_products_'.$site->language)
        ->elementType(\craft\commerce\elements\Product::class)
        ->criteria(function (\craft\commerce\elements\db\ProductQuery $query) use ($site) {
        $query->siteId = $site->id;
        return $query;
    })
    ->transformer(function (\craft\commerce\elements\Product $product) {
        Craft::$app->getConfig()->getGeneral()->generateTransformsBeforePageLoad = true;
        return (new \modules\mymodule\services\MyModuleService)->transformProductData($product);
    });
}

When I change a common value between all sites (like status, price, weight etc) only the index of the site the product was saved on is updating. Is it possible to re-index across all sites upon save; So - change price, save, all site indices are updated with the correct price.

Does scout offer this functionality?

a-am commented 3 months ago

@epapada did you find a solution for this? We are having same issue with just entries.

janhenckens commented 3 months ago

This ia a pretty old issue @a-am feel free to create a new one and share your scout config if you can - that makes it easier to debug.