New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrating attribute value page #32475
Migrating attribute value page #32475
Conversation
behats failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a conflict, maybe it's the cause of the behat failure? I let you check 👍
Blocked by PrestaShop/blockwishlist#226 since bug in blockwishlist causes exceptino during attribute value deletion. |
2823965
to
16cb986
Compare
admin-dev/themes/new-theme/js/pages/attribute/form/attribute-form-map.ts
Outdated
Show resolved
Hide resolved
src/Adapter/Attribute/QueryHandler/GetAttributeForEditingHandler.php
Outdated
Show resolved
Hide resolved
src/Core/Domain/AttributeGroup/Attribute/QueryResult/EditableAttribute.php
Outdated
Show resolved
Hide resolved
src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml
Outdated
Show resolved
Hide resolved
tests/Integration/Behaviour/Features/Context/Domain/AttributeFeatureContext.php
Outdated
Show resolved
Hide resolved
tests/Integration/Behaviour/Features/Context/Domain/AttributeFeatureContext.php
Outdated
Show resolved
Hide resolved
aeb98d4
to
01ec887
Compare
Argh 😞 a rebase is needed |
01ec887
to
b1864b4
Compare
@@ -306,9 +357,15 @@ private function getErrorMessages() | |||
'Admin.Notifications.Error' | |||
); | |||
|
|||
$wrongValueMessage = $this->trans( | |||
'A field is invalid.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an existing wording for when a field has a wrong value but we don't know what field it is ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but you can also "explode" the exception array here based on the const from the AttributeConstraintException
class which would allow you to use specific error messages for each field instead
1a512e1
to
f2e66d7
Compare
383eb34
to
7cb7834
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @matthieu-rolland
Sorry for the HUUUGGE review, especially since most of the code was not done by you but there are many things that don't follow the conventions and should be improved I went through a thorough review though, so I shouldn't have any other comments for this one
admin-dev/themes/new-theme/js/pages/attribute/form/attribute-form-map.ts
Outdated
Show resolved
Hide resolved
tests/Integration/Behaviour/Features/Scenario/Attribute/attribute_management.feature
Show resolved
Hide resolved
tests/Integration/Behaviour/Features/Scenario/Attribute/attribute_management.feature
Show resolved
Hide resolved
@@ -56,7 +56,7 @@ public function createAttributeGroup(string $reference, TableNode $node): void | |||
{ | |||
$data = $this->localizeByRows($node); | |||
|
|||
$attributeGroupId = $this->createAttributeGroupUsingCommand($data['name'], $data['public_name'], $data['type']); | |||
$attributeGroupId = $this->createAttributeGroupUsingCommand([1 => $data['name']], [1 => $data['public_name']], $data['type']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this was modified with hard coded values, but the initial implementation that handled localized values more accurately was better as it really allowed checking the multi-lang fields And the implementation was cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well it was failing because it formerly didn't use the CQRS command, and then when using the CQRS command the expected format was not the same, I'll see how I can have it working with previous test implementation and current CQRS command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use multi-lang values like name[en-US]
like in many other behat tests, coupled with the localizeByRows
and similar methods this should be doable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still doesn't rely on localized values 🤔
And language with iso code "en" is the default one | ||
And language "language2" with locale "fr-FR" exists | ||
And I create attribute group "attributeGroup1" with specified properties: | ||
| name | Color | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous implementation with actual localized values was better, this should be refactored/reverted a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one appeared after rebase... I was not sure which one to keep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know this is worth looking into it to understand why this was changed
But the modification is on this PR so it's unlikely this was done in another PR But the attribute group is a multi lang entity, so is its command so it should be tested with multiple languages
src/Adapter/AttributeGroup/CommandHandler/EditAttributeGroupHandler.php
Outdated
Show resolved
Hide resolved
src/Adapter/AttributeGroup/QueryHandler/GetAttributeGroupForEditingHandler.php
Outdated
Show resolved
Hide resolved
src/PrestaShopBundle/Resources/config/services/core/form/form_builder.yml
Outdated
Show resolved
Hide resolved
src/PrestaShopBundle/Resources/config/services/core/form/form_handler.yml
Outdated
Show resolved
Hide resolved
And language with iso code "en" is the default one | ||
And language "language2" with locale "fr-FR" exists | ||
And I create attribute group "attributeGroup1" with specified properties: | ||
| name | Color | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know this is worth looking into it to understand why this was changed
But the modification is on this PR so it's unlikely this was done in another PR But the attribute group is a multi lang entity, so is its command so it should be tested with multiple languages
@@ -56,7 +56,7 @@ public function createAttributeGroup(string $reference, TableNode $node): void | |||
{ | |||
$data = $this->localizeByRows($node); | |||
|
|||
$attributeGroupId = $this->createAttributeGroupUsingCommand($data['name'], $data['public_name'], $data['type']); | |||
$attributeGroupId = $this->createAttributeGroupUsingCommand([1 => $data['name']], [1 => $data['public_name']], $data['type']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use multi-lang values like name[en-US]
like in many other behat tests, coupled with the localizeByRows
and similar methods this should be doable
/** | ||
* @var int default shop id from configs | ||
*/ | ||
private $defaultShopId; | ||
|
||
public function __construct() | ||
{ | ||
$this->defaultShopId = CommonFeatureContext::getContainer()->get('prestashop.adapter.legacy.configuration')->get('PS_SHOP_DEFAULT'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @var int default shop id from configs | |
*/ | |
private $defaultShopId; | |
public function __construct() | |
{ | |
$this->defaultShopId = CommonFeatureContext::getContainer()->get('prestashop.adapter.legacy.configuration')->get('PS_SHOP_DEFAULT'); | |
} |
26a0cf5
to
5db7330
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
if (null !== $command->getLocalizedValue()) { | ||
$attribute->name = $command->getLocalizedValue(); | ||
//$propertiesToUpdate['name'] = array_keys($command->getLocalizedValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP? Or commented code to delete?
|
||
trait LocalizedObjectModelTrait | ||
{ | ||
protected function fillLocalizedValues(ObjectModel $product, string $propertyName, array $localizedValues, array &$updatableProperties): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes PR #34892 has been merged and file
protected function fillLocalizedValues(ObjectModel $product, string $propertyName, array $localizedValues, array &$updatableProperties): void |
exists on develop
…eatureContext.php Co-authored-by: Jonathan Lelievre <jo.lelievre@gmail.com>
Co-authored-by: Jonathan Lelievre <jo.lelievre@gmail.com>
4cc2a7c
to
332494d
Compare
…he others and handle partial update and better validation
…d redirection to All shops context has been fixed
…ndle multishop association field
332494d
to
68ab72a
Compare
Blocked by PrestaShop/blockwishlist#226