-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Add swatch option: Prevent loosing data and default value if data is not populated via adminhtml #12036
Conversation
…not populated via adminhtml
I didn't see that issue :( , but it appears to be working in that scenario too |
@gomencal Thank you for such precise fix. As this is a fix of API it would be good to cover it with an integration or api-functional test. Feel free to ask any help to implement them. |
); | ||
|
||
$this->assertTrue($response); | ||
$updatedData = $this->getAttributeOptions($testAttributeCode); |
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.
getAttributeOptions
Method is not defined.
const RESOURCE_PATH = '/V1/products/attributes'; | ||
|
||
/** | ||
* @magentoApiDataFixture Magento/Catalog/Model/Product/Attribute/_files/swatch_attribute.php |
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.
No need to introduce new fixture. Use Magento/Swatches/_files/swatch_attribute.php
@@ -0,0 +1,48 @@ | |||
<?php |
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 fixture is not correct.
- Rollback is required. Otherwise, an exception
Exception occurred when running the "\/magento2\/magento2ce\/dev\/tests\/integration\/testsuite\/Magento\/Catalog\/Model\/Product\/Attribute\/_files\/swatch_attribute.php" fixture: Magento\Framework\Exception\AlreadyExistsException: Attribute with the same code already exists.
is thrown:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
);
$attribute->loadByCode(4, 'swatch_attribute');
if ($attribute->getId()) {
$attribute->delete();
}
- Attribute is not configured well and tests failed in all data sets with message
{"message":"Attribute %1 doesn't work with options","parameters":["swatch_attribute"],"trace":"#0 \/magento2\/magento2ce\/app\/code\/Magento\/Catalog\/Model\/Product\/Attribute\/OptionManagement.php(57): Magento\\Eav\\Model\\Entity\\Attribute\\OptionManagement->add('catalog_product', 'swatch_attribut...', Object(Magento\\Eav\\Model\\Entity\\Attribute\\Option))\n#1 [internal function]: Magento\\Catalog\\Model\\Product\\Attribute\\OptionManagement->add('swatch_attribut...', Object(Magento\\Eav\\Model\\Entity\\Attribute\\Option))\n#2 \/magento2\/magento2ce\/app\/code\/Magento\/Webapi\/Controller\/Rest.php(330): call_user_func_array(Array, Array)\n#3 \/magento2\/magento2ce\/app\/code\/Magento\/Webapi\/Controller\/Rest.php(239): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#4 \/magento2\/magento2ce\/lib\/internal\/Magento\/Framework\/Interception\/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#5 \/magento2\/magento2ce\/lib\/internal\/Magento\/Framework\/Interception\/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#6 \/magento2\/magento2ce\/lib\/internal\/Magento\/Framework\/Interception\/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#7 \/magento2\/magento2ce\/generated\/code\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(39): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#8 \/magento2\/magento2ce\/lib\/internal\/Magento\/Framework\/App\/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#9 \/magento2\/magento2ce\/generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php(24): Magento\\Framework\\App\\Http->launch()\n#10 \/magento2\/magento2ce\/lib\/internal\/Magento\/Framework\/App\/Bootstrap.php(256): Magento\\Framework\\App\\Http\\Interceptor->launch()\n#11 \/magento2\/magento2ce\/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#12 {main}"}
Seems insted of introduction new fixture and resolve these issues fixture dev/tests/integration/testsuite/Magento/Swatches/_files/swatch_attribute.php
may be reused.
Hi @vkublytskyi ! thanks for your feedback! If you see ok the changes I'll apply them to 2.3 and 2.1. |
…lue if data is not populated via adminhtml #12036
[EngCom] Public Pull Requests - 2.2-develop - MAGETWO-83552: save invoice ID on credit memo when using API method salesRefundInvoiceV1 #11670 - MAGETWO-82577: [Backport 2.2] Translate order getCreatedAtFormatted() to store locale #11422 - MAGETWO-84474: 10128: New Orders not being saved to order grid #12241 - MAGETWO-83783: Shipping method fixtures not compatible with getShippingMethod(true) in OrderCreateTest #12227 - MAGETWO-83290: Add swatch option: Prevent loosing data and default value if data is not populated via adminhtml #12036 - MAGETWO-83741: 11740: Sending emails from Admin in Multi-Store Environment defaults to Primary Store #11992 - MAGETWO-83399: Fix for remove 'product_list_toolbar' block from layout in XML #9413 #11473
Add swatch option: Prevent loosing data and default value if data is not populated via adminhtml.
Description
Adapt \Magento\Swatches\Model\Plugin\EavAttribute::setProperOptionsArray to make possible that the plugins afterSave in the same module doesn't delete data if they don't found this data with all the options data, as sent via adminhtml form.
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist