Skip to content
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

Conversation

JevgenijVisockij
Copy link
Contributor

@JevgenijVisockij JevgenijVisockij commented May 8, 2023

Questions Answers
Branch? develop
Description? Migrates attribute value form to symfony
Type? refacto
Category? BO
BC breaks? no
Deprecations? no
How to test? CI green and UI tests green, functional QA will be done in the last PR
UI Tests https://github.com/jolelievre/ga.tests.ui.pr/actions/runs/7786548308
Fixed ticket? Fix #33126

Blocked by PrestaShop/blockwishlist#226

@JevgenijVisockij JevgenijVisockij requested a review from a team as a code owner May 8, 2023 07:31
@prestonBot prestonBot added develop Branch Refactoring Type: Refactoring labels May 8, 2023
@zuk3975
Copy link
Contributor

zuk3975 commented May 8, 2023

behats failing

Copy link
Contributor

@matthieu-rolland matthieu-rolland left a 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 👍

@JevgenijVisockij
Copy link
Contributor Author

Blocked by PrestaShop/blockwishlist#226 since bug in blockwishlist causes exceptino during attribute value deletion.

@JevgenijVisockij JevgenijVisockij force-pushed the migrate-view-attribute-value-fixed branch from 2823965 to 16cb986 Compare June 28, 2023 07:34
@matks
Copy link
Contributor

matks commented Aug 28, 2023

Argh 😞 a rebase is needed

@@ -306,9 +357,15 @@ private function getErrorMessages()
'Admin.Notifications.Error'
);

$wrongValueMessage = $this->trans(
'A field is invalid.',
Copy link
Contributor

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 ?

Copy link
Contributor

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

@Hlavtox
Copy link
Contributor

Hlavtox commented Nov 24, 2023

@matthieu-rolland matthieu-rolland force-pushed the migrate-view-attribute-value-fixed branch 3 times, most recently from 1a512e1 to f2e66d7 Compare December 21, 2023 15:39
@M0rgan01 M0rgan01 added this to the 9.0.0 milestone Dec 29, 2023
Copy link
Contributor

@jolelievre jolelievre left a 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

install-dev/data/xml/feature_flag.xml Outdated 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']);
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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 |
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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

tests/Integration/Behaviour/behat.yml Show resolved Hide resolved
tests/Integration/Behaviour/behat.yml 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 |
Copy link
Contributor

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']);
Copy link
Contributor

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

Comment on lines 47 to 62
/**
* @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');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/**
* @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');
}

@matthieu-rolland matthieu-rolland force-pushed the migrate-view-attribute-value-fixed branch from 26a0cf5 to 5db7330 Compare January 30, 2024 15:08
Copy link
Contributor

@matks matks left a comment

Choose a reason for hiding this comment

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

Good for me

Nothing to add to @jolelievre review 👍

Just provided 2 little suggestions not blocking


if (null !== $command->getLocalizedValue()) {
$attribute->name = $command->getLocalizedValue();
//$propertiesToUpdate['name'] = array_keys($command->getLocalizedValue());
Copy link
Contributor

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
Copy link
Contributor

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

@jolelievre jolelievre force-pushed the migrate-view-attribute-value-fixed branch 2 times, most recently from 4cc2a7c to 332494d Compare February 5, 2024 15:06
jolelievre
jolelievre previously approved these changes Feb 5, 2024
tests/Integration/Behaviour/behat.yml Show resolved Hide resolved
@ps-jarvis ps-jarvis added the Waiting for QA Status: action required, waiting for test feedback label Feb 5, 2024
@jolelievre jolelievre removed the Waiting for QA Status: action required, waiting for test feedback label Feb 5, 2024
@jolelievre jolelievre merged commit 25e0dda into PrestaShop:develop Feb 5, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
develop Branch Refactoring Type: Refactoring
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Finish Migrating Catalog > Attributes & Features > Attribute Group > Add / edit attribute value
9 participants