Coding to create a store with Magento I found a 'problem' I would like to solve.
Whenever I open the file system in Magento using Wysiwyg, the folders are not sorted at all.
I would like to have the folders sorted by name ASC. I tried modiying the Storage class by creating a preference of vendor\magento\module-cms\Model\Wysiwyg\Images\Storage.php
and it actually works for images inside but not for folders!
My big question is, how can I sort this folder collection by name? Where can I find the files for this changes?
Thanks!
CodePudding user response:
The \Magento\Cms\Model\Wysiwyg\Images\Storage
class has method getDirsCollection
Extend it by calling setOrder
setter
$collection = $this->getCollection($path)
->setCollectDirs(true)
->setCollectFiles(false)
->setCollectRecursively(false)
// ===> setter <===
->setOrder(
'name',
\Magento\Framework\Data\Collection::SORT_ORDER_ASC
)
;