Merge pull request #4011 from devansh-webkul/attribute_position_issue

Fixed select type attribute position is not working in layered navigation #3891
This commit is contained in:
Jitendra Singh 2020-10-07 12:30:51 +05:30 committed by GitHub
commit 4e891b2199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -159,7 +159,11 @@ class CatalogRuleRepository extends Repository
if ($attribute->code == 'tax_category_id') {
$options = $this->getTaxCategories();
} else {
$options = $attribute->options;
if ($attribute->type === 'select') {
$options = $attribute->options()->orderBy('sort_order')->get();
} else {
$options = $attribute->options;
}
}
if ($attribute->validation == 'decimal')

View File

@ -65,12 +65,14 @@ class Category extends TranslatableModel implements CategoryContract
*/
public function filterableAttributes()
{
return $this->belongsToMany(AttributeProxy::modelClass(), 'category_filterable_attributes')->with('options');
return $this->belongsToMany(AttributeProxy::modelClass(), 'category_filterable_attributes')->with(['options' => function($query) {
$query->orderBy('sort_order');
}]);
}
/**
* Getting the root category of a category
*
*
* @return Category
*/
public function getRootCategory(): Category
@ -124,7 +126,7 @@ class Category extends TranslatableModel implements CategoryContract
if ($category->id === $this->id) {
return $category;
}
return $this->findInTree($category->children);
}
}