Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add Asset Indexing as a cli action #2980

Closed
sergeifilippov opened this issue Jun 11, 2018 · 4 comments
Closed

Feature Request: Add Asset Indexing as a cli action #2980

sergeifilippov opened this issue Jun 11, 2018 · 4 comments
Labels
assets 📁 features related to asset management enhancement improvements to existing features

Comments

@sergeifilippov
Copy link

It would be great to be able to run Asset Indexing via the craft cli.

@brandonkelly brandonkelly added enhancement improvements to existing features assets 📁 features related to asset management labels Jun 12, 2018
@timkelty
Copy link
Contributor

Converting the indexing process to a Yii queue is pretty critical for any site with a sizeable amount of assets.

We've run into all sort of problems with indexing (latest being #2876 (comment)), which makes indexing basically a "cross your fingers" operation, that's nearly impossible to debug.

@ryanpcmcquen
Copy link

Is there a way to index assets from a migration script?

@brandonkelly
Copy link
Member

Not currently.

@ryanpcmcquen
Copy link

This works for me inside of a migration script for indexing assets on a specific volume:

        try {
            if ($volume = Craft::$app->getVolumes()->getVolumeByHandle('VOLUME_HANDLE')) {
                foreach (Craft::$app->getAssetIndexer()->getIndexListOnVolume($volume) as $item) {
                    Craft::$app->getAssetIndexer()->indexFile(
                        $volume,
                        $item['path'],
                        '',
                        false
                    );
                }

            } else {
                return false;
            }
            return true;

        } catch (\Throwable $e) {
            echo $e->getMessage();
            return false;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assets 📁 features related to asset management enhancement improvements to existing features
Projects
None yet
Development

No branches or pull requests

4 participants