-
Notifications
You must be signed in to change notification settings - Fork 9.4k
MC-40031: [UX] Configurations are not preserved on form reload when new configurable product creation fails #32194
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
Conversation
Hi @mastiuhin-olexandr. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
@magento run Functional Tests B2B |
1 similar comment
@magento run Functional Tests B2B |
@@ -130,11 +158,18 @@ public function execute() | |||
$resource->getAttribute('news_from_date')->setMaxValue($product->getNewsToDate()); | |||
$resource->getAttribute('custom_design_from')->setMaxValue($product->getCustomDesignTo()); | |||
|
|||
$this->validateUrlKeyUniqueness($product); |
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 not perform validation in controller
It is better to do it inside
\Magento\Catalog\Model\ResourceModel\Product::validate
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 think it should stay in controller, because other requests also has this validation.
@magento run all tests |
@magento run Functional Tests EE |
@Magneto run Functional Tests B2B |
@magento run Functional Tests B2B |
7 similar comments
@magento run Functional Tests B2B |
@magento run Functional Tests B2B |
@magento run Functional Tests B2B |
@magento run Functional Tests B2B |
@magento run Functional Tests B2B |
@magento run Functional Tests B2B |
@magento run Functional Tests B2B |
\Magento\Catalog\Model\ProductFactory $productFactory, | ||
ProductUrlPathGenerator $productUrlPathGenerator, | ||
UrlFinderInterface $urlFinder, | ||
GetStoresListByWebsiteIds $getStoresListByWebsiteIds |
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.
added constructor parameters should be nullable and should be initialized inside constructor
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.
Thank you, fixed.
@magento run all tests |
* @param Product $product | ||
* @return array Array of conflicting Url Keys. | ||
*/ | ||
public function findUrlKeyConflicts(Product $product): array |
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.
A Validator
class with a method findUrlKeyConflicts
probably doesn't make much sense, I would recommend actually changing it to validateUrlKeyConflicts
and throw the exception here. Make this method a void instead, there is no point to return the URL keys if they won't be used.
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.
Also, agree with Myroslav, the generation should happen on controller and be a parameter on this function. If the information from product that we need is just ID, probably just use it as parameter instead of whole product object.
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 am not sure that rework this to passing UrlKey parameter is a good idea.
In this case the most of logic will stay in the controller. Because there is a function that is using for UrlPath generation
$this->productUrlPathGenerator->getUrlPathWithSuffix($product, $store->getId());
,
that uses a product model. The only what will left in the validator is "findAllByData" and the pieace of program that checks found rewrites are not belong to a product.
The other pieace of program generating urlKey, generating urlPathes of stores, searching storeIds of websites (as workaround for performance) will be in the controller.
Please check the last changes and then confirm or deny that it should be reworked like you said before.
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.
Thank you, fixed. Validator now throws exception. And method renamed.
foreach ($urlRewrites as $urlRewrite) { | ||
if (in_array($urlRewrite->getRequestPath(), $storeIdsToPathForSave) | ||
&& isset($storeIdsToPathForSave[$urlRewrite->getStoreId()]) | ||
&& $storeIdsToPathForSave[$urlRewrite->getStoreId()] == $urlRewrite->getRequestPath() |
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.
Please use ===
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.
Fixed
if (in_array($urlRewrite->getRequestPath(), $storeIdsToPathForSave) | ||
&& isset($storeIdsToPathForSave[$urlRewrite->getStoreId()]) | ||
&& $storeIdsToPathForSave[$urlRewrite->getStoreId()] == $urlRewrite->getRequestPath() | ||
&& $product->getId() != $urlRewrite->getEntityId()) { |
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.
Please use !==
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.
Fixed.
$storeIdsToPathForSave = []; | ||
$searchData = [ | ||
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE, | ||
UrlRewrite::REQUEST_PATH => [] |
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.
add comma
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.
Fixed.
…ew configurable product creation fails
…ew configurable product creation fails
@magento run all tests |
@magento run Functional Tests B2B |
@magento run Functional Tests B2B, WebAPI Tests |
@magento run WebAPI Tests |
Hi @gabrieldagama, thank you for the review.
|
@zakdma the branch with code successfully imported into |
@zakdma, an error occurred during the Pull Request import. |
1 similar comment
@zakdma, an error occurred during the Pull Request import. |
@zakdma the branch with code successfully imported into |
Hi @mastiuhin-olexandr, thank you for your contribution! |
Description (*)
This is a usability issue.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Actual: Form is reloaded. Error is displayed:
The value specified in the URL Key field would generate a URL that already exists.
The variations you configured have disappeared. Information that has to be entered manually and requires significant time is lost.
Expected: To be identified by UX team.
OR
Contribution checklist (*)