Fix/checkboxlist multiple values#17
Open
skrezh wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a
checkboxlistproperty has multiple values selected (e.g.["Drinks", "Sauces"]), the filter should allow selecting a single option and show all products where that option is part of the array.Problem
The
checkboxlistproperty type does not work correctly when multiple values are selected. When a product has several values (e.g.,["Drinks", "Sauces"]), the following issues occur:PropertyValue::getValueAttribute()returns raw JSON string instead of an arrayPropertyValue::getDisplayValueAttribute()displays raw JSON instead of a comma-separated listPropertyValue::beforeSave()generates an incorrectindex_value(slug of the whole JSON string)UniquePropertyValuesInCategoriesQuerygroups by the entire JSON array, so multi-value entries don't appear as separate filter optionsProductEntry::mapProps()/VariantEntry::mapProps()don't split checkboxlist values into individual index entries, breakingJSON_CONTAINSfilteringProperty::getValuesForCategory()throws "Cannot access offset of type array" when sorting valuesPropertyFields::checkboxlist()passes array tojson_decode()causing a TypeError in backendChanges
models/PropertyValue.php: Handlecheckboxlisttype ingetValueAttribute()(return array),getDisplayValueAttribute()(comma-separated string), andbeforeSave()(dot-separated slugs asindex_value)classes/queries/UniquePropertyValuesInCategoriesQuery.php: Addget()method that expands JSON arrays into individual filter entriesclasses/index/ProductEntry.php&VariantEntry.php: Split dot-separatedindex_valueinto individual array elements inmapProps()models/Property.php: Fix sorting whenvalueis an arrayformwidgets/PropertyFields.php: Fixjson_decode()receiving array instead of string