shopware / shopware

Shopware 6 is an open commerce platform based on Symfony Framework and Vue and supported by a worldwide community and more than 1.500 community extensions
https://shopware.com
MIT License
2.8k stars 1.02k forks source link

Sorting of available variants in backend (/admin) by variant name or custom order possible? #2019

Closed tobiasgraeber closed 2 months ago

tobiasgraeber commented 3 years ago

PHP Version

7.4

Shopware Version

6.4.3.0

Expected behaviour

Sorting the "Available variants" table after variant generation in the backend by "Variant" (first row) should sort the variants by name.

Actual behaviour

Despite sorting, the variants are displayed in the backend completely mixed up. Unfortunately, we can't find any logic behind why this is sorted in such a jumbled way. Espacially sorting by the Variants Name (first row).

grafik

How to reproduce

Create for example variantes (shoes) with different colors and sizes. Colors should be named for example "Schwarz", "Grau-Grün", "Grau-Pink", "Rot", "Schwarz-Pink", "Schwarz-Grau" etc.

If you click on "variante" to sort, it shows:

Grau-Grün - 37 Grau-Pink - 37 Schwarz-Pink - 37 Schwarz - 37 Schwarz-Grün 37 Grau - 37 Grau-Pink - 36 ...

Instead of:

Grau - 37 Grau-Grün - 37 Grau-Pink - 37 Grau-Pink - 36 ... Schwarz - 37 Schwarz-Grün 37 Schwarz-Pink - 37

or at least any alphabetical order etc....

Could somebody provide me with some guidance here where the sorting is handled in the code or which options we have to possibly influence this? Is this a mistake? What possibilities are there to store an own sorting?

Also see: https://issues.shopware.com/issues/NEXT-14047 and https://issues.shopware.com/issues/NEXT-11362 which seems similar

At least can somebody please explain after which creterias sorting takes place here?

Thanks!

tobiasgraeber commented 3 years ago

Looking at:

https://github.com/shopware/platform/blob/trunk/src/Administration/Resources/app/administration/src/module/sw-product/component/sw-product-variants/sw-product-variants-overview/index.js#L172

Here the "sorting" is done, by ID and GroupID currently, in line 174 + 175 using Criteria.sort('product.options.groupId', this.sortDirection) and Criteria.sort('product.options.id', this.sortDirection) .

to me this seems incorrect.

PLEASE NOTE: On the first quick look in the backend, sorting by name seems right - but looking more closely if you have more then 10 variantes wit at least two different options, its not sorted alwas the same (alphabetically) - at least no real logic seems to be applied here....

If you look at a search result from the API:

grafik

Variants using two option pairs like color and size can never be sorted correctly/alphabetically like this. Or?

How to adjust the Criteria.sort correctly here, like with https://developer.shopware.com/docs/guides/plugins/plugins/administration/using-data-handling ?

...

I am performing my search query (via https://shopware.stoplight.io/docs/store-api/docs/concepts/search-queries.md) with this raw body data:


{"page":1,"limit":25,"filter":[{"type":"equals","field":"product.parentId","value":"43a23e0c03bf4ceabc6055a2185faa87"}],"sort":[{"field":"product.options.groupId","order":"ASC","naturalSorting":false},{"field":"product.options.id","order":"ASC","naturalSorting":false}],"associations":{"media":{"total-count-mode":1},"options":{"sort":[{"field":"groupId","order":"ASC","naturalSorting":false},{"field":"id","order":"ASC","naturalSorting":false}
,{"field":"name","order":"ASC","naturalSorting":false}
],"total-count-mode":1}},"total-count-mode":1}

Any help would be highly appreciated - thanks

MarcelSchmaeing commented 2 months ago

Hello,

Within our company roadmap and work capacity, we try to address each bug or improvement request but admit that not each one will be resolved. To continue our culture of honesty and openness, we are closing this issue to focus on our roadmap on behalf of all Shopware users.

If you feel like this issue is still impacting you, please create a new issue and let us know. Thank you again for your valuable feedback.