Skip to content

Commit 7b33900

Browse files
authored
LYNX-183: Add filters to attributesList query (#132)
1 parent 9630af6 commit 7b33900

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

app/code/Magento/Catalog/Test/Fixture/Attribute.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class Attribute implements RevertibleDataFixtureInterface
3434
'is_filterable_in_grid' => true,
3535
'position' => 0,
3636
'apply_to' => [],
37-
'is_searchable' => '0',
38-
'is_visible_in_advanced_search' => '0',
39-
'is_comparable' => '0',
40-
'is_used_for_promo_rules' => '0',
41-
'is_visible_on_front' => '0',
42-
'used_in_product_listing' => '0',
37+
'is_searchable' => false,
38+
'is_visible_in_advanced_search' => false,
39+
'is_comparable' => false,
40+
'is_used_for_promo_rules' => false,
41+
'is_visible_on_front' => false,
42+
'used_in_product_listing' => false,
4343
'is_visible' => true,
4444
'scope' => 'store',
4545
'attribute_code' => 'product_attribute%uniqid%',

app/code/Magento/CatalogGraphQl/Model/Output/AttributeMetadata.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ public function execute(
5252
}
5353

5454
$metadata = [
55-
'is_searchable' => $attribute->getIsSearchable() === "1",
56-
'is_filterable' => $attribute->getIsFilterable() === "1",
5755
'is_comparable' => $attribute->getIsComparable() === "1",
56+
'is_filterable' => $attribute->getIsFilterable() === "1",
57+
'is_filterable_in_search' => $attribute->getIsFilterableInSearch() === "1",
58+
'is_searchable' => $attribute->getIsSearchable() === "1",
5859
'is_html_allowed_on_front' => $attribute->getIsHtmlAllowedOnFront() === "1",
5960
'is_used_for_price_rules' => $attribute->getIsUsedForPriceRules() === "1",
60-
'is_filterable_in_search' => $attribute->getIsFilterableInSearch() === "1",
61-
'used_in_product_listing' => $attribute->getUsedInProductListing() === "1",
62-
'is_wysiwyg_enabled' => $attribute->getIsWysiwygEnabled() === "1",
6361
'is_used_for_promo_rules' => $attribute->getIsUsedForPromoRules() === "1",
62+
'is_visible_in_advanced_search' => $attribute->getIsVisibleInAdvancedSearch() === "1",
63+
'is_visible_on_front' => $attribute->getIsVisibleOnFront() === "1",
64+
'is_wysiwyg_enabled' => $attribute->getIsWysiwygEnabled() === "1",
65+
'used_in_product_listing' => $attribute->getUsedInProductListing() === "1",
6466
'apply_to' => null
6567
];
6668

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,16 +540,18 @@ enum AttributeEntityTypeEnum {
540540
}
541541

542542
type CatalogAttributeMetadata implements CustomAttributeMetadataInterface @doc(description: "Catalog attribute metadata.") {
543-
is_filterable_in_search: Boolean! @doc(description: "Whether a product or category attribute can be filtered in search or not.")
544-
used_in_product_listing: Boolean! @doc(description: "Whether a product or category attribute is used in product listing or not.")
545-
is_searchable: Boolean! @doc(description: "Whether a product or category attribute can be searched or not.")
546-
is_filterable: Boolean! @doc(description: "Whether a product or category attribute can be filtered or not.")
547-
is_comparable: Boolean! @doc(description: "Whether a product or category attribute can be compared against another or not.")
548-
is_html_allowed_on_front: Boolean! @doc(description: "Whether a product or category attribute can use HTML on front or not.")
549-
is_used_for_price_rules: Boolean! @doc(description: "Whether a product or category attribute can be used for price rules or not.")
550-
is_wysiwyg_enabled: Boolean! @doc(description: "Whether a product or category attribute has WYSIWYG enabled or not.")
551-
is_used_for_promo_rules: Boolean! @doc(description: "Whether a product or category attribute is used for promo rules or not.")
552543
apply_to: [CatalogAttributeApplyToEnum] @doc(description: "To which catalog types an attribute can be applied.")
544+
is_comparable: Boolean @doc(description: "Whether a product or category attribute can be compared against another or not.")
545+
is_filterable: Boolean @doc(description: "Whether a product or category attribute can be filtered or not.")
546+
is_filterable_in_search: Boolean @doc(description: "Whether a product or category attribute can be filtered in search or not.")
547+
is_html_allowed_on_front: Boolean @doc(description: "Whether a product or category attribute can use HTML on front or not.")
548+
is_searchable: Boolean @doc(description: "Whether a product or category attribute can be searched or not.")
549+
is_used_for_price_rules: Boolean @doc(description: "Whether a product or category attribute can be used for price rules or not.")
550+
is_used_for_promo_rules: Boolean @doc(description: "Whether a product or category attribute is used for promo rules or not.")
551+
is_visible_in_advanced_search: Boolean @doc(description: "Whether a product or category attribute is visible in advanced search or not.")
552+
is_visible_on_front: Boolean @doc(description: "Whether a product or category attribute is visible on front or not.")
553+
is_wysiwyg_enabled: Boolean @doc(description: "Whether a product or category attribute has WYSIWYG enabled or not.")
554+
used_in_product_listing: Boolean @doc(description: "Whether a product or category attribute is used in product listing or not.")
553555
}
554556

555557
enum CatalogAttributeApplyToEnum {

app/code/Magento/EavGraphQl/etc/schema.graphqls

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ input AttributeInputSelectedOption @doc(description: "Specifies selected option
158158
}
159159

160160
input AttributeFilterInput @doc(description: "An input object that specifies the filters used for attributes.") {
161-
is_filterable_in_search: Boolean @doc(description: "Whether a product or category attribute can be filtered in search or not.")
162-
used_in_product_listing: Boolean @doc(description: "Whether a product or category attribute is used in product listing or not.")
163161
is_comparable: Boolean @doc(description: "Whether a product or category attribute can be compared against another or not.")
164-
is_searchable: Boolean @doc(description: "Whether a product or category attribute can be searched or not.")
165162
is_filterable: Boolean @doc(description: "Whether a product or category attribute can be filtered or not.")
163+
is_filterable_in_search: Boolean @doc(description: "Whether a product or category attribute can be filtered in search or not.")
166164
is_html_allowed_on_front: Boolean @doc(description: "Whether a product or category attribute can use HTML on front or not.")
165+
is_searchable: Boolean @doc(description: "Whether a product or category attribute can be searched or not.")
167166
is_used_for_price_rules: Boolean @doc(description: "Whether a product or category attribute can be used for price rules or not.")
168-
is_wysiwyg_enabled: Boolean @doc(description: "Whether a product or category attribute has WYSIWYG enabled or not.")
169167
is_used_for_promo_rules: Boolean @doc(description: "Whether a product or category attribute is used for promo rules or not.")
170168
is_visible_in_advanced_search: Boolean @doc(description: "Whether a product or category attribute is visible in advanced search or not.")
171169
is_visible_on_front: Boolean @doc(description: "Whether a product or category attribute is visible on front or not.")
170+
is_wysiwyg_enabled: Boolean @doc(description: "Whether a product or category attribute has WYSIWYG enabled or not.")
171+
used_in_product_listing: Boolean @doc(description: "Whether a product or category attribute is used in product listing or not.")
172172
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/GetProductWithCustomAttributesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
[
3131
'entity_type_id' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID,
3232
'attribute_code' => 'product_custom_attribute',
33+
'is_comparable' => 1,
3334
'is_visible_on_front' => 1
3435
],
3536
'varchar_custom_attribute'
@@ -222,7 +223,7 @@ public function testGetProductCustomAttributesFiltered()
222223
{
223224
sku
224225
name
225-
custom_attributesV2(filters: {is_visible_on_front: true}) {
226+
custom_attributesV2(filters: {is_comparable: true, is_visible_on_front: true}) {
226227
items {
227228
code
228229
... on AttributeValue {

dev/tests/api-functional/testsuite/Magento/GraphQl/EavGraphQl/AttributesListTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ public function testAttributesListFilterForCatalogProductEntityType(): void
216216
attributesList(entityType: CATALOG_PRODUCT, filters: {is_visible_on_front: true, is_comparable: true}) {
217217
items {
218218
code
219+
... on CatalogAttributeMetadata {
220+
is_comparable
221+
is_visible_on_front
222+
}
219223
}
220224
errors {
221225
type
@@ -229,8 +233,10 @@ public function testAttributesListFilterForCatalogProductEntityType(): void
229233
[
230234
'attributesList' => [
231235
'items' => [
232-
0 => [
233-
'code' => $this->catalogAttribute4->getAttributeCode()
236+
0 => [
237+
'code' => $this->catalogAttribute4->getAttributeCode(),
238+
'is_comparable' => true,
239+
'is_visible_on_front' => true
234240
]
235241
],
236242
'errors' => []
@@ -247,6 +253,9 @@ public function testAttributesListAnyFilterApply(): void
247253
attributesList(entityType: CUSTOMER, filters: {is_filterable: true}) {
248254
items {
249255
code
256+
... on CatalogAttributeMetadata {
257+
is_filterable
258+
}
250259
}
251260
errors {
252261
type

0 commit comments

Comments
 (0)