Skip to content

Commit 1503882

Browse files
committed
Add basic feature file
1 parent 7ab05b2 commit 1503882

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
@managing_inventory
2+
Feature: Filtering products
3+
In order to find a product I am into
4+
As a Customer
5+
I want to be able to filter products by specific criteria
6+
7+
Background:
8+
Given the store operates on a channel named "Web-US" in "USD" currency
9+
And there are 15 t-shirts in the store
10+
And 5 of these products are priced between "$10" and "$15"
11+
And 10 of these products are priced between "$15" and "$35"
12+
And these "products" have "size" option
13+
And 3 of these products have "size" option with "S" value
14+
And 5 of these products have "size" option with "M" value
15+
And 7 of these products have "size" option with "M" value
16+
And these "products" have "color" attribute
17+
And 3 of these products have "color" attribute with "Red" value
18+
And 5 of these products have "color" attribute with "Green" value
19+
And 7 of these products have "color" attribute with "Blue" value
20+
21+
@ui
22+
Scenario: Filtering products by name
23+
When I go to the shop products page
24+
And I search the products by "shirt" phase
25+
Then I should see 9 products on the first page
26+
And I should see 6 products on the second page
27+
28+
@ui
29+
Scenario: Filtering products by options
30+
When I go to the shop products page
31+
And I filter products by "S" "Size" option
32+
And I filter products by "M" "Size" option
33+
Then I should see 8 products on the page
34+
35+
@ui
36+
Scenario: Filtering products by attributes
37+
When I go to the shop products page
38+
And I filter products by "Red" "Color" attribute
39+
And I filter products by "Green" "Color" attribute
40+
Then I should see 8 products on the page
41+
42+
@ui
43+
Scenario: Filtering products by price
44+
When I go to the shop products page
45+
And I filter product price between 10 and 15
46+
Then I should see 5 products on the page
47+
48+
@ui
49+
Scenario: Changing limit to from 9 to 18
50+
Given there are 40 more products in the store
51+
When I go to the products page
52+
And I change the limit to 18
53+
Then I should see 18 products on the first page
54+
And I should see 18 products on the second page
55+
And I should see 9 products on the third page
56+
57+
@ui
58+
Scenario: Changing limit to from 9 to 36
59+
Given there are 40 more products in the store
60+
When I go to the products page
61+
And I change the limit to 36
62+
Then I should see 36 products on the first page
63+
And I should see 9 products on the second page

src/Form/Type/ChoiceMapper/ProductAttributesMapper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ public function mapToChoices(ProductAttributeInterface $productAttribute): array
6060
array_walk($attributeValues, function (ProductAttributeValueInterface $productAttributeValue) use (&$choices): void {
6161
$value = $productAttributeValue->getValue();
6262
$configuration = $productAttributeValue->getAttribute()->getConfiguration();
63+
$product = $productAttributeValue->getProduct();
64+
6365
if (is_array($value)
6466
&& isset($configuration['choices'])
65-
&& is_array($configuration['choices'])) {
67+
&& is_array($configuration['choices'])
68+
) {
6669
foreach ($value as $singleValue) {
6770
$choice = $this->stringFormatter->formatToLowercaseWithoutSpaces($singleValue);
6871
$label = $configuration['choices'][$singleValue][$this->localeContext->getLocaleCode()];

0 commit comments

Comments
 (0)