Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ProductAttribute] Fix select product attribute choice value rename#8737

Merged
pamil merged 4 commits into
Sylius:1.0from
GSadee:select-attribute-rename-fix
Sep 29, 2017
Merged

[ProductAttribute] Fix select product attribute choice value rename#8737
pamil merged 4 commits into
Sylius:1.0from
GSadee:select-attribute-rename-fix

Conversation

@GSadee
Copy link
Copy Markdown
Member

@GSadee GSadee commented Sep 26, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related tickets partially fixes #8308
License MIT

This PR fixes losing reference to an attribute value on a product when select attribute choice value renames.

@GSadee GSadee added the Bug Fix label Sep 26, 2017
@GSadee GSadee added this to the 1.1 milestone Sep 26, 2017
@GSadee GSadee force-pushed the select-attribute-rename-fix branch from 787fabd to bd7d87c Compare September 26, 2017 11:16
@pamil
Copy link
Copy Markdown
Contributor

pamil commented Sep 26, 2017

Can we split these two fixes to two standalone PRs? Would be easier to review & merge then :)

@GSadee GSadee force-pushed the select-attribute-rename-fix branch from bd7d87c to 9c4dd2d Compare September 26, 2017 12:18
@pamil
Copy link
Copy Markdown
Contributor

pamil commented Sep 26, 2017

Btw. as these are bugfixes, it should be targeted against 1.0

@pamil pamil modified the milestones: 1.1, 1.0 Sep 26, 2017
@pamil pamil changed the base branch from master to 1.0 September 26, 2017 12:18
@GSadee GSadee changed the title [WIP][ProductAttribute] Select product attribute fixes [ProductAttribute] Fix select product attribute value rename Sep 26, 2017
@GSadee GSadee force-pushed the select-attribute-rename-fix branch 3 times, most recently from b7f8395 to e209bae Compare September 27, 2017 06:51
string $productAttributeType,
string $productAttributeName,
string $attributeValue,
string $language = 'en_US'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the language set to the last "([^"]+)"?

) {
$attribute = $this->provideProductAttribute($productAttributeType, $productAttributeName);
$attribute->setConfiguration(['multiple' => false, 'choices' => [$attributeValue], 'min' => null, 'max' => null]);
$attributeValue = $this->createProductAttributeValue(array_keys($values), $attribute, $language);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's $values defined?

/**
* @Given /^(this product) has (.+?) attribute "([^"]+)" with value "([^"]+)", "([^"]+)"$/
*/
public function thisProductHasSelectAttributeWithValue(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an abandoned step.

@@ -232,6 +253,25 @@ public function iWantToSeeAllProductAttributesInStore()
$this->indexPage->open();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't feel right reading this step, what about the something like: the administrator changes this product attribute value "foo" to "bar"?

* @return string
*/
private function getValidFormKey(string $value): string
private function getValidFormKey(): string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getValidFormKey -> getUniqueKey?

"green": "green",
"black": "black"
},
"choices": @array@,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should change it to something like:

{
 "@string@": "yellow",
 "@string@": "green",
 // etc..
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know and I agree that current example doesn't check behaviour properly, but this feature is not implemented in php-matcher (there is even an issue: coduo/php-matcher#92)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding an additional assertion in the test file, eg. asserting that the response matches this file contents + getting $response['configuration']['choices'] and asserting they are what we expect (like https://github.com/Sylius/SyliusElasticSearchPlugin/blob/master/tests/Controller/SearchControllerApiTest.php#L436)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

And I specify its code as "mug_material"
And I name it "Mug material" in "English (United States)"
And I add material "-100% Banana Skin"
And I add value "-100% Banana Skin"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value is kinda misleading, my first - AttributeValue, the second - the same. What about naming it an "option" or a "select option"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we have values in configuration of a product attribute, so I wanted to be consistent with the layout:
zrzut ekranu 2017-09-28 o 15 54 29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the reasoning behind it, but it's still confusing, not sure whether we should solve it already or leave it as is :)

@GSadee GSadee force-pushed the select-attribute-rename-fix branch from e209bae to 32583a8 Compare September 28, 2017 13:56
@GSadee GSadee changed the title [ProductAttribute] Fix select product attribute value rename [ProductAttribute] Fix select product attribute choice value rename Sep 29, 2017
Copy link
Copy Markdown
Contributor

@pamil pamil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix that API test and it's good to go! 🎉

And I specify its code as "mug_material"
And I name it "Mug material" in "English (United States)"
And I add material "-100% Banana Skin"
And I add value "-100% Banana Skin"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the reasoning behind it, but it's still confusing, not sure whether we should solve it already or leave it as is :)

"green": "green",
"black": "black"
},
"choices": @array@,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding an additional assertion in the test file, eg. asserting that the response matches this file contents + getting $response['configuration']['choices'] and asserting they are what we expect (like https://github.com/Sylius/SyliusElasticSearchPlugin/blob/master/tests/Controller/SearchControllerApiTest.php#L436)?

@pamil pamil merged commit dee7829 into Sylius:1.0 Sep 29, 2017
@pamil
Copy link
Copy Markdown
Contributor

pamil commented Sep 29, 2017

Thank you Rzegś! 🎉

@GSadee GSadee deleted the select-attribute-rename-fix branch September 29, 2017 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants